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
|
||||
|
||||
|
||||
_dirsplit()
|
||||
{
|
||||
OLDIFS="$IFS"
|
||||
IFS=/
|
||||
set -- $1
|
||||
IFS="$OLDIFS"
|
||||
dir=""
|
||||
while [ $# -gt 1 ]; do
|
||||
dir="$dir$1/"
|
||||
shift
|
||||
done
|
||||
base="$1"
|
||||
}
|
||||
|
||||
|
||||
_do()
|
||||
{
|
||||
DIR="$1"
|
||||
|
|
@ -61,10 +76,8 @@ redo()
|
|||
if [ -e "$i/." ]; then
|
||||
i="$i/all"
|
||||
fi
|
||||
D="$(dirname "$i")/"
|
||||
[ "$D" = "./" ] && D=""
|
||||
B="$(basename "$i")"
|
||||
( cd "$D" && _do "$D" "$B" ) || exit $?
|
||||
_dirsplit "$i"
|
||||
( cd "$dir" && _do "$dir" "$base" ) || exit $?
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue