SHA256
1
0
forked from pool/quilt
quilt/quilt-boost-the-speed-of-series-applied-and-unapplied.patch
Jean Delvare 3a7d64b475 Backport functional and performance regression fixes from upstream:
* Fix bash completion of patch names
* Fix refresh error message
* Fix quilt diff -z on file names including spaces
* Fix quilt files output when there are no files
* Fix patches heuristic for unapplied patches with timestamps
* Re-enable testing of patch-wrapper
* Fix performance regression in quilt patches
* Performance boost for series, applies and unapplied commands

OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=78
2014-04-25 16:11:32 +00:00

98 lines
2.5 KiB
Diff

From: Jean Delvare <jdelvare@suse.de>
Date: Sun, 2 Mar 2014 16:29:24 +0100
Subject: Boost the speed of the series, applied and unapplied commands
Patch-mainline: yes
Git-commit: e052a2d22569f56a30285716da11b4e0a1eed052
References: bnc#872719
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
@@ -976,6 +976,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: