Optimize the noop operation. The only use case in quilt is to ensure
that files have a link count of 1, so we can check that OPT_NOLINKS
is set once and for all, instead of checking again with every file.

Signed-off-by: Jean Delvare <[email protected]>
Reviewed-by: Raphael Hertzog <[email protected]>
---
 quilt/scripts/backup-files.in |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -151,18 +151,17 @@ remove()
        rmdir -p "${backup%/*}" 2> /dev/null || true
 }
 
-noop()
+noop_nolinks()
 {
        local file=$1
 
-       if [ -e "$file" ] && [ -n "$OPT_NOLINKS" ]; then
+       if [ -e "$file" ]; then
                ensure_nolinks "$file"
        fi
 }
 
 
 ECHO=echo
-OPT_WHAT=noop
 while [ $# -gt 0 ]; do
        case $1 in
        -b)     OPT_WHAT=backup
@@ -210,6 +209,14 @@ if [ "$1" = - ] && [ ! -d "$OPT_PREFIX"
        exit 1
 fi
 
+if [ -z "$OPT_WHAT" ]; then
+       if [ -n "$OPT_NOLINKS" ]; then
+               OPT_WHAT=noop_nolinks
+       else
+               exit 0
+       fi
+fi
+
 if [ -n "$OPT_FILE" ]; then
        cat "$OPT_FILE" \
        | while read nextfile; do


_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to