minimal/do: write my own replacements for dirname and basename.
This greatly reduces the number of fork+exec calls, so in particular, t/curse/all.do now runs much faster: /bin/sh (bash): was 5.9s, now 2.2s /bin/dash: was 3.2s, now 1.1s Obviously improving the speed of minimal/do doesn't really matter, except that it makes a good benchmark to compare the "real" redo against. So far it's losing badly: 5.4s.
This commit is contained in:
parent
f62176f809
commit
81cbe49938
1 changed files with 17 additions and 4 deletions
21
minimal/do
21
minimal/do
|
|
@ -16,6 +16,21 @@ if [ -z "$DO_BUILT" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
_dirsplit()
|
||||||
|
{
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=/
|
||||||
|
set -- $1
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
dir=""
|
||||||
|
while [ $# -gt 1 ]; do
|
||||||
|
dir="$dir$1/"
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
base="$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_do()
|
_do()
|
||||||
{
|
{
|
||||||
DIR="$1"
|
DIR="$1"
|
||||||
|
|
@ -61,10 +76,8 @@ redo()
|
||||||
if [ -e "$i/." ]; then
|
if [ -e "$i/." ]; then
|
||||||
i="$i/all"
|
i="$i/all"
|
||||||
fi
|
fi
|
||||||
D="$(dirname "$i")/"
|
_dirsplit "$i"
|
||||||
[ "$D" = "./" ] && D=""
|
( cd "$dir" && _do "$dir" "$base" ) || exit $?
|
||||||
B="$(basename "$i")"
|
|
||||||
( cd "$D" && _do "$D" "$B" ) || exit $?
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue