diff options
author | Jason Evans <jasone@canonware.com> | 2012-04-03 13:20:21 -0700 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2012-04-03 13:20:21 -0700 |
commit | 12a6845b6c91cf76caf3199495d76b16bba1f2fe (patch) | |
tree | 3b21bdb5c8474457b891a183d24955ebf4f655fc /include/jemalloc/internal/size_classes.sh | |
parent | 9d4d76874d888986e611bd9c9a0c905841956c4d (diff) | |
download | jemalloc-12a6845b6c91cf76caf3199495d76b16bba1f2fe.tar.gz |
Use $((...)) instead of expr.
Use $((...)) for math in size_classes.h rather than expr, because it is
much faster. This is not supported syntax in the classic Bourne shell,
but all modern sh implementations support it, including bash, zsh, and
ash.
Diffstat (limited to 'include/jemalloc/internal/size_classes.sh')
-rwxr-xr-x | include/jemalloc/internal/size_classes.sh | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/include/jemalloc/internal/size_classes.sh b/include/jemalloc/internal/size_classes.sh index 9829a2b..3d23613 100755 --- a/include/jemalloc/internal/size_classes.sh +++ b/include/jemalloc/internal/size_classes.sh @@ -17,8 +17,8 @@ pow2() { e=$1 pow2_result=1 while [ ${e} -gt 0 ] ; do - pow2_result=`expr ${pow2_result} + ${pow2_result}` - e=`expr ${e} - 1` + pow2_result=$((${pow2_result} + ${pow2_result})) + e=$((${e} - 1)) done } @@ -45,7 +45,7 @@ EOF bin=0 psz=0 sz=${t} - delta=`expr ${sz} - ${psz}` + delta=$((${sz} - ${psz})) cat <<EOF /* SIZE_CLASS(bin, delta, sz) */ #define SIZE_CLASSES \\ @@ -56,30 +56,30 @@ EOF cat <<EOF SIZE_CLASS(${bin}, ${delta}, ${sz}) \\ EOF - bin=`expr ${bin} + 1` + bin=$((${bin} + 1)) psz=${sz} - sz=`expr ${sz} + ${sz}` - delta=`expr ${sz} - ${psz}` + sz=$((${sz} + ${sz})) + delta=$((${sz} - ${psz})) done # Quantum-multiple size classes. For each doubling of sz, as many as 4 # size classes exist. Their spacing is the greater of: # - q # - sz/4, where sz is a power of 2 while [ ${sz} -lt ${p} ] ; do - if [ ${sz} -ge `expr ${q} \* 4` ] ; then - i=`expr ${sz} / 4` + if [ ${sz} -ge $((${q} * 4)) ] ; then + i=$((${sz} / 4)) else i=${q} fi - next_2pow=`expr ${sz} \* 2` + next_2pow=$((${sz} * 2)) while [ ${sz} -lt $next_2pow ] ; do cat <<EOF SIZE_CLASS(${bin}, ${delta}, ${sz}) \\ EOF - bin=`expr ${bin} + 1` + bin=$((${bin} + 1)) psz=${sz} - sz=`expr ${sz} + ${i}` - delta=`expr ${sz} - ${psz}` + sz=$((${sz} + ${i})) + delta=$((${sz} - ${psz})) done done cat <<EOF @@ -89,11 +89,11 @@ EOF #endif EOF - lg_p=`expr ${lg_p} + 1` + lg_p=$((${lg_p} + 1)) done - lg_t=`expr ${lg_t} + 1` + lg_t=$((${lg_t} + 1)) done - lg_q=`expr ${lg_q} + 1` + lg_q=$((${lg_q} + 1)) done cat <<EOF |