diff options
author | Jean Delvare <jdelvare@suse.de> | 2012-02-01 18:08:49 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2012-02-01 18:08:49 +0100 |
commit | 112ca01df0bc5a0815ba6cca7d8eb95dbc6091c3 (patch) | |
tree | aec590e2fe2c2d817f81a8e25588195c037e752c | |
parent | 275532ad427f507ac6c4dcf08d41080cb57576b0 (diff) | |
download | quilt-112ca01df0bc5a0815ba6cca7d8eb95dbc6091c3.tar.gz |
backup-files: Skip echo-only loops in silent mode
In silent mode, loops which do nothing but print messages turn into
no-ops. Skip them completely to save some time.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r-- | quilt.changes | 9 | ||||
-rw-r--r-- | quilt/scripts/backup-files.in | 27 |
2 files changed, 23 insertions, 13 deletions
diff --git a/quilt.changes b/quilt.changes index a553490..f74a5e9 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Wed Feb 1 17:23:39 CET 2012 - jdelvare@suse.de + +- backup-files: 32 performance improvements, developed during Suse + Hack Week VI (February 2010.) This speeds up backup-files by a + factor 50, roughly, bringing it close enough to the original C + implementation. Many thanks to Raphael Hertzog for reviewing + most of the series. + +------------------------------------------------------------------- Wed Feb 1 17:06:24 CET 2012 - jdelvare@suse.de - Finally get rid of the old C implementation of backup-files, diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in index b0151b5..07557e7 100644 --- a/quilt/scripts/backup-files.in +++ b/quilt/scripts/backup-files.in @@ -67,6 +67,17 @@ ensure_nolinks() { fi } +notify_action() +{ + [ $ECHO != : ] || return 0 + local action=$1 filename=$2 + + while read -d $'\0' -r + do + $ECHO "$action ${REPLY#./}" + done < "$filename" +} + backup() { local file=$1 local backup=$OPT_PREFIX$file @@ -140,11 +151,7 @@ restore_all() if [ -s "$EMPTY_FILES" ]; then xargs -0 rm -f < "$EMPTY_FILES" - - while read -d $'\0' -r - do - $ECHO "Removing ${REPLY#./}" - done < "$EMPTY_FILES" + notify_action Removing "$EMPTY_FILES" fi if [ -s "$NONEMPTY_FILES" ]; then @@ -157,10 +164,7 @@ restore_all() xargs -0 cp -l --parents --remove-destination \ --target-directory="$target_dir" \ < "$NONEMPTY_FILES" 2>&4); then - while read -d $'\0' -r - do - $ECHO "Restoring ${REPLY#./}" - done < "$NONEMPTY_FILES" + notify_action Restoring "$NONEMPTY_FILES" else (cd "$OPT_PREFIX" && find . -type d -print0) \ | xargs -0 mkdir -p @@ -243,10 +247,7 @@ copy_many() if xargs -0 cp -p --parents --target-directory="$OPT_PREFIX" \ < "$NONEMPTY_FILES" 2>&4; then - while read -d $'\0' -r - do - $ECHO "Copying $REPLY" - done < "$NONEMPTY_FILES" + notify_action Copying "$NONEMPTY_FILES" else while read -d $'\0' -r do |