quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 23/39] backup-files: Optimize noop


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 23/39] backup-files: Optimize noop
Date: Sat, 19 Mar 2011 10:52:53 +0100
User-agent: quilt/0.48-17.1

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 <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
 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




reply via email to

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