Use echo instead of cat in loops in size_classes.sh

This avoids fork/exec()ing in loops, as echo is a builtin, and makes
size_classes.sh much faster (from > 10s to < 0.2s on mingw on my machine).
This commit is contained in:
Mike Hommey 2012-04-16 16:30:23 +02:00 committed by Jason Evans
parent 2d04f5e5ff
commit 72ca7220f2

View File

@ -35,10 +35,8 @@ while [ ${lg_q} -le ${lg_qmax} ] ; do
while [ ${lg_t} -le ${lg_q} ] ; do while [ ${lg_t} -le ${lg_q} ] ; do
lg_p=${lg_pmin} lg_p=${lg_pmin}
while [ ${lg_p} -le ${lg_pmax} ] ; do while [ ${lg_p} -le ${lg_pmax} ] ; do
cat <<EOF echo "#if (LG_TINY_MIN == ${lg_t} && LG_QUANTUM == ${lg_q} && LG_PAGE == ${lg_p})"
#if (LG_TINY_MIN == ${lg_t} && LG_QUANTUM == ${lg_q} && LG_PAGE == ${lg_p}) echo "#define SIZE_CLASSES_DEFINED"
#define SIZE_CLASSES_DEFINED
EOF
pow2 ${lg_q}; q=${pow2_result} pow2 ${lg_q}; q=${pow2_result}
pow2 ${lg_t}; t=${pow2_result} pow2 ${lg_t}; t=${pow2_result}
pow2 ${lg_p}; p=${pow2_result} pow2 ${lg_p}; p=${pow2_result}
@ -46,16 +44,12 @@ EOF
psz=0 psz=0
sz=${t} sz=${t}
delta=$((${sz} - ${psz})) delta=$((${sz} - ${psz}))
cat <<EOF echo "/* SIZE_CLASS(bin, delta, sz) */"
/* SIZE_CLASS(bin, delta, sz) */ echo "#define SIZE_CLASSES \\"
#define SIZE_CLASSES \\
EOF
# Tiny size classes. # Tiny size classes.
while [ ${sz} -lt ${q} ] ; do while [ ${sz} -lt ${q} ] ; do
cat <<EOF echo " SIZE_CLASS(${bin}, ${delta}, ${sz}) \\"
SIZE_CLASS(${bin}, ${delta}, ${sz}) \\
EOF
bin=$((${bin} + 1)) bin=$((${bin} + 1))
psz=${sz} psz=${sz}
sz=$((${sz} + ${sz})) sz=$((${sz} + ${sz}))
@ -73,22 +67,18 @@ EOF
fi fi
next_2pow=$((${sz} * 2)) next_2pow=$((${sz} * 2))
while [ ${sz} -lt $next_2pow ] ; do while [ ${sz} -lt $next_2pow ] ; do
cat <<EOF echo " SIZE_CLASS(${bin}, ${delta}, ${sz}) \\"
SIZE_CLASS(${bin}, ${delta}, ${sz}) \\
EOF
bin=$((${bin} + 1)) bin=$((${bin} + 1))
psz=${sz} psz=${sz}
sz=$((${sz} + ${i})) sz=$((${sz} + ${i}))
delta=$((${sz} - ${psz})) delta=$((${sz} - ${psz}))
done done
done done
cat <<EOF echo
echo "#define NBINS ${bin}"
#define NBINS ${bin} echo "#define SMALL_MAXCLASS ${psz}"
#define SMALL_MAXCLASS ${psz} echo "#endif"
#endif echo
EOF
lg_p=$((${lg_p} + 1)) lg_p=$((${lg_p} + 1))
done done
lg_t=$((${lg_t} + 1)) lg_t=$((${lg_t} + 1))