quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 1/2] patches: Optimize processing of unapplied patche


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 1/2] patches: Optimize processing of unapplied patches
Date: Sun, 09 Feb 2014 15:56:21 +0100

* Don't check for $strip = ab twice, once is enough.
* Quote the file names to be suitable in regular expressions only
  once, instead of doing it again for every patch. This fixes a
  performance regression introduced in 8ebb056d ("patches: Add
  support for multiple files"), sorry about that.

These two simple changes bring a huge performance boost on unapplied
patches, of about 50% in the single file case and growing as you add
files.
---
 quilt/patches.in |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

--- a/quilt/patches.in
+++ b/quilt/patches.in
@@ -70,7 +70,6 @@ scan_applied()
 touched_by_patch()
 {
        local strip=$1 patch=$2
-       [ $strip = ab ] && strip=1
        cat_file $(patch_file_name $patch) \
        |  awk '
        /^(\+\+\+|---)[ \t]/ {
@@ -89,7 +88,14 @@ scan_unapplied()
 {
        local color=$1 prefix=$2 strip
        shift 2
-       local patch file file_bre match
+       local patch file match
+       local -a files_bre
+
+       # Quote each file name only once
+       for file in "address@hidden"
+       do
+               address@hidden"$(quote_bre "$file")"
+       done
 
        for patch in "$@"
        do
@@ -97,11 +103,10 @@ scan_unapplied()
                [ "$strip" = ab ] && strip=1
 
                match=
-               for file in "address@hidden"
+               for file in "address@hidden"
                do
-                       file_bre="$(quote_bre "$file")"
                        if touched_by_patch $strip $patch \
-                          | grep -q "^$file_bre\$"
+                          | grep -q "^$file\$"
                        then
                                match=1
                                break

-- 
Jean Delvare
Suse L3 Support




reply via email to

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