summaryrefslogtreecommitdiffstats
path: root/bin/ecompress
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-06-21 23:42:52 +0000
committerMike Frysinger <vapier@gentoo.org>2007-06-21 23:42:52 +0000
commit22efe874cea08a376d745a64fb231d4ced330ce1 (patch)
treef0386d77ad0f2b6628be8d11c0d9d8e3268e522e /bin/ecompress
parent1d3954d9fb6c47fad9177fff5bd9a31981ac013d (diff)
downloadportage-22efe874cea08a376d745a64fb231d4ced330ce1.tar.gz
portage-22efe874cea08a376d745a64fb231d4ced330ce1.tar.bz2
portage-22efe874cea08a376d745a64fb231d4ced330ce1.zip
cache the result of --suffix to reduce testing overhead as suggested by Mr_Bones_
svn path=/main/trunk/; revision=6922
Diffstat (limited to 'bin/ecompress')
-rwxr-xr-xbin/ecompress31
1 files changed, 17 insertions, 14 deletions
diff --git a/bin/ecompress b/bin/ecompress
index 046e546fb..bf886e1c4 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -24,20 +24,23 @@ case $1 in
--suffix)
[[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
- set -e
- tmpdir="${T}"/.ecompress$$.${RANDOM}
- mkdir "${tmpdir}"
- cd "${tmpdir}"
- # we have to fill the file enough so that there is something
- # to compress as some programs will refuse to do compression
- # if it cannot actually compress the file
- echo {0..1000} > compressme
- ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
- suffix=$(ls compressme*)
- suffix=${suffix#compressme}
- cd /
- rm -rf "${tmpdir}"
- echo "${suffix}"
+ if [[ ! -e ${T}/.ecompress.suffix ]] ; then
+ set -e
+ tmpdir="${T}"/.ecompress$$.${RANDOM}
+ mkdir "${tmpdir}"
+ cd "${tmpdir}"
+ # we have to fill the file enough so that there is something
+ # to compress as some programs will refuse to do compression
+ # if it cannot actually compress the file
+ echo {0..1000} > compressme
+ ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
+ suffix=$(ls compressme*)
+ suffix=${suffix#compressme}
+ cd /
+ rm -rf "${tmpdir}"
+ echo "${suffix}" > "${T}/.ecompress.suffix"
+ fi
+ cat "${T}/.ecompress.suffix"
;;
--bin)
[[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2