{"thread":{"id":"2245","subject":"[PATCH] Make cg-clean faster and space-safe","startedAt":"2005-10-28T02:39:21Z","lastAt":"2005-10-28T02:39:21Z","messageCount":1,"participants":["Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10732","messageId":"1130467161.2186.25.camel@dv","threadId":"2245","inReplyTo":null,"subject":"[PATCH] Make cg-clean faster and space-safe","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-10-28T02:39:21Z","receivedAt":"2005-10-28T02:39:21Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Use bash pattern matching to list all parent directories instead of\nusing arrays.  This makes cg-clean run twice as fast on the Linux kernel\n(4 seconds vs 8 seconds).\n\nThe new code is also for directory names containing spaces and other\nsymbols that need to be quoted.  Also, the new code is easier to read.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/cg-clean b/cg-clean\nindex ea00d2b..f7b5151 100755\n--- a/cg-clean\n+++ b/cg-clean\n@@ -53,16 +53,12 @@ clean_dirs()\n \tgit-ls-files --cached |\n \t\tsed -n 's|^'\"$_git_relpath\"'||p' |\n \t\tsed -n 's|/[^/]*$||p' |\n-\t\twhile IFS='/' read -a dir; do\n-\t\t\ti=0\n-\t\t\twhile test $i != ${#dir[@]}; do\n-\t\t\t\tj=0\n-\t\t\t\twhile test $i != $j; do\n-\t\t\t\t\techo -n ${dir[$j]}/\n-\t\t\t\t\tj=$[$j+1]\n-\t\t\t\tdone\n-\t\t\t\techo ${dir[$i]}\n-\t\t\t\ti=$[$i+1]\n+\t\twhile read dir; do\n+\t\t\twhile true; do\n+\t\t\t\techo \"$dir\"\n+\t\t\t\tupdir=\"${dir%/*}\"\n+\t\t\t\ttest \"$dir\" = \"$updir\" && break\n+\t\t\t\tdir=\"$updir\"\n \t\t\tdone\n \t\tdone |\n \t\tsort -u >\"$dirlist\"\n\n\n-- \nRegards,\nPavel Roskin\n"}]}