diff options
author | Jean Delvare <jdelvare@suse.de> | 2014-02-15 18:43:41 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2014-02-15 18:43:41 +0100 |
commit | 1b95644e3a00f07a6711c881d2dcdac14206a57e (patch) | |
tree | 9f12faf33fe36ffa75ffcca7d6ae51c91506a016 | |
parent | d62e6cdff01c3c920c48cc7d52bde41f327df25b (diff) | |
download | quilt-1b95644e3a00f07a6711c881d2dcdac14206a57e.tar.gz |
patches: Optimize processing of unapplied patches
* 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.
-rw-r--r-- | quilt/patches.in | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/quilt/patches.in b/quilt/patches.in index 3f3caed..6ec5e01 100644 --- 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 "${opt_files[@]}" + do + files_bre[${#files_bre[@]}]=$(quote_bre "$file") + done for patch in "$@" do @@ -97,11 +103,10 @@ scan_unapplied() [ "$strip" = ab ] && strip=1 match= - for file in "${opt_files[@]}" + for file in "${files_bre[@]}" do - file_bre="$(quote_bre "$file")" if touched_by_patch $strip $patch \ - | grep -q "^$file_bre\$" + | grep -q "^$file\$" then match=1 break |