quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] Boost the speed of the series, applied and unapplied


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] Boost the speed of the series, applied and unapplied commands
Date: Fri, 28 Feb 2014 09:52:39 +0100

The current implementation of the series, applied and unapplied
commands performs rather poorly, especially on large patch sets. To
make things worse, bash completion makes use of these commands, so
it becomes next to unusable on large patch sets.

Instead of looping over each patch, use the power of printf to print
everything in one go. Performance gains on a 15k patch series are
breathtaking:

series:    189.4 s -> 0.6 s
series -v:  92.9 s -> 0.6 s
applied:     3.5 s -> 0.1 s
unapplied:   3.9 s -> 0.1 s
---
 quilt/applied.in          |    5 +----
 quilt/scripts/patchfns.in |    8 ++++++++
 quilt/series.in           |    9 ++++-----
 quilt/unapplied.in        |   10 ++--------
 4 files changed, 15 insertions(+), 17 deletions(-)

--- a/quilt/applied.in
+++ b/quilt/applied.in
@@ -61,10 +61,7 @@ patch=$(find_applied_patch "$1") || exit
 
 setup_pager
 
-for patch in $(applied_before "$patch") $patch
-do
-       echo "$(print_patch $patch)"
-done
+printf "$(patch_format)\n" $(applied_before "$patch") "$patch"
 
 ### Local Variables:
 ### mode: shell-script
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -949,6 +949,14 @@ print_patch() {
        echo -n "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1"
 }
 
+# Generate a format suitable to print patch names with printf
+patch_format()
+{
+       local prefix=${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}
+
+       echo -n "${prefix/\%/%%}%s"
+}
+
 setup_colors()
 {
        local 
C=diff_hdr=32:diff_add=36:diff_mod=35:diff_rem=35:diff_hunk=33:diff_ctx=35:diff_cctx=33:patch_offs=33:patch_fuzz=35:patch_fail=31:series_app=32:series_top=33:series_una=00:clear=00
--- a/quilt/series.in
+++ b/quilt/series.in
@@ -40,12 +40,11 @@ cat_patches()
 {
        local color=$1 prefix=$2
        shift 2
-       local patch
 
-       for patch in "$@"
-       do
-               echo "$color$prefix$(print_patch "$patch")$color_clear"
-       done
+       if [ $# -ge 1 ]
+       then
+               printf "$color$prefix$(patch_format)$color_clear\n" "$@"
+       fi
 }
 
 options=`getopt -o vh --long color:: -- "$@"`
--- a/quilt/unapplied.in
+++ b/quilt/unapplied.in
@@ -67,14 +67,8 @@ fi
 
 setup_pager
 
-(
-       echo "$patch"
-       patches_after "$patch"
-) \
-| while read patch
-do
-       echo "$(print_patch $patch)"
-done
+printf "$(patch_format)\n" "$patch" $(patches_after "$patch")
+
 ### Local Variables:
 ### mode: shell-script
 ### End:

-- 
Jean Delvare
Suse L3 Support




reply via email to

[Prev in Thread] Current Thread [Next in Thread]