pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/wrapper Do not load the $cache file for every argum...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ff19c93e718c
branches:  trunk
changeset: 535773:ff19c93e718c
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Nov 28 14:45:22 2007 +0000

description:
Do not load the $cache file for every argument. Instead, load it once
and then call it as a shell function. Note that the shell function is
not called "cache", since some shells have problems when a function has
the same name as a variable.

This speeds up the wrapper by as little as 75 percent for the final link
command of editors/abiword on SunOS-5.10-sparc (before: 20 seconds,
after: 5 seconds).

diffstat:

 mk/wrapper/bsd.wrapper.mk |  4 ++--
 mk/wrapper/logic          |  9 ++++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diffs (58 lines):

diff -r 45077eef7d1d -r ff19c93e718c mk/wrapper/bsd.wrapper.mk
--- a/mk/wrapper/bsd.wrapper.mk Wed Nov 28 13:19:35 2007 +0000
+++ b/mk/wrapper/bsd.wrapper.mk Wed Nov 28 14:45:22 2007 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.wrapper.mk,v 1.74 2007/11/28 13:18:50 rillig Exp $
+# $NetBSD: bsd.wrapper.mk,v 1.75 2007/11/28 14:45:22 rillig Exp $
 #
 # Copyright (c) 2005 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -615,7 +615,7 @@
 .  if !target(${_WRAP_CACHE.${_wrappee_}})
 ${_WRAP_CACHE.${_wrappee_}}:
        ${RUN} ${MKDIR} ${.TARGET:H}
-       ${RUN} echo "cachehit=no" > ${.TARGET}
+       ${RUN} echo "cache_lookup() { cachehit=no; }" > ${.TARGET}
 .  endif
 
 .  if !target(${_WRAP_CACHE_BODY.${_wrappee_}})
diff -r 45077eef7d1d -r ff19c93e718c mk/wrapper/logic
--- a/mk/wrapper/logic  Wed Nov 28 13:19:35 2007 +0000
+++ b/mk/wrapper/logic  Wed Nov 28 14:45:22 2007 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: logic,v 1.15 2007/09/13 10:50:43 rillig Exp $
+# $NetBSD: logic,v 1.16 2007/11/28 14:45:22 rillig Exp $
 #
 # Copyright (c) 2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,6 +35,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 # Empty out the argument buffer and fill up the command buffer.
+. $cache
 skipargs=0
 while ! queue_is_empty argbuf; do
        #
@@ -79,7 +80,7 @@
        #
        case $do_transform in
        yes)
-               . $cache
+               cache_lookup
                case $cachehit in
                yes)
                        # The cache was hit and $arg is set.
@@ -135,10 +136,12 @@
                                $cat >> $cache_body << EOF
 $cachearg) arg=$cachedarg; split_arg=$split_arg; cachehit=yes ;;
 EOF
-                               { echo "case \$arg in"
+                               { echo "cache_lookup() {"
+                                 echo "case \$arg in"
                                  $cat $cache_body
                                  echo "*) cachehit=no ;;"
                                  echo "esac"
+                                 echo "}"
                                } > $cache-$$.tmp
                                $mv -f $cache-$$.tmp $cache
                                ;;



Home | Main Index | Thread Index | Old Index