* [PATCH] Make cg-clean faster and space-safe
@ 2005-10-28 2:39 Pavel Roskin
0 siblings, 0 replies; only message in thread
From: Pavel Roskin @ 2005-10-28 2:39 UTC (permalink / raw)
To: git, Petr Baudis
Use bash pattern matching to list all parent directories instead of
using arrays. This makes cg-clean run twice as fast on the Linux kernel
(4 seconds vs 8 seconds).
The new code is also for directory names containing spaces and other
symbols that need to be quoted. Also, the new code is easier to read.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/cg-clean b/cg-clean
index ea00d2b..f7b5151 100755
--- a/cg-clean
+++ b/cg-clean
@@ -53,16 +53,12 @@ clean_dirs()
git-ls-files --cached |
sed -n 's|^'"$_git_relpath"'||p' |
sed -n 's|/[^/]*$||p' |
- while IFS='/' read -a dir; do
- i=0
- while test $i != ${#dir[@]}; do
- j=0
- while test $i != $j; do
- echo -n ${dir[$j]}/
- j=$[$j+1]
- done
- echo ${dir[$i]}
- i=$[$i+1]
+ while read dir; do
+ while true; do
+ echo "$dir"
+ updir="${dir%/*}"
+ test "$dir" = "$updir" && break
+ dir="$updir"
done
done |
sort -u >"$dirlist"
--
Regards,
Pavel Roskin
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-28 2:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-28 2:39 [PATCH] Make cg-clean faster and space-safe Pavel Roskin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).