Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make While it is nice to have the same function do b...



details:   https://anonhg.NetBSD.org/src/rev/3b9e1676b33d
branches:  trunk
changeset: 785119:3b9e1676b33d
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Feb 24 19:43:37 2013 +0000

description:
While it is nice to have the same function do both the upper case and
lower case conversion, it ends up eating 4% of the total time we spend
in make calling tolower() while building libc.

diffstat:

 usr.bin/make/var.c |  50 +++++++++++++-------------------------------------
 1 files changed, 13 insertions(+), 37 deletions(-)

diffs (91 lines):

diff -r 0c4b3b43c5a8 -r 3b9e1676b33d usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Feb 24 06:21:36 2013 +0000
+++ b/usr.bin/make/var.c        Sun Feb 24 19:43:37 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.172 2012/11/15 16:42:26 christos Exp $       */
+/*     $NetBSD: var.c,v 1.173 2013/02/24 19:43:37 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.172 2012/11/15 16:42:26 christos Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.173 2013/02/24 19:43:37 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.172 2012/11/15 16:42:26 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.173 2013/02/24 19:43:37 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -309,7 +309,6 @@
                           int, const char **, int, int *, int *,
                           VarPattern *);
 static char *VarQuote(char *);
-static char *VarChangeCase(char *, int);
 static char *VarHash(char *);
 static char *VarModify(GNode *, Var_Parse_State *,
     const char *,
@@ -2344,37 +2343,6 @@
    return Buf_Destroy(&buf, FALSE);
 }
 
-/*-
- *-----------------------------------------------------------------------
- * VarChangeCase --
- *      Change the string to all uppercase or all lowercase
- *
- * Input:
- *     str             String to modify
- *     upper           TRUE -> uppercase, else lowercase
- *
- * Results:
- *      The string with case changed
- *
- * Side Effects:
- *      None.
- *
- *-----------------------------------------------------------------------
- */
-static char *
-VarChangeCase(char *str, int upper)
-{
-   Buffer         buf;
-   int            (*modProc)(int);
-
-   modProc = (upper ? toupper : tolower);
-   Buf_Init(&buf, 0);
-   for (; *str ; str++) {
-       Buf_AddByte(&buf, modProc(*str));
-   }
-   return Buf_Destroy(&buf, FALSE);
-}
-
 static char *
 VarStrftime(const char *fmt, int zulu)
 {
@@ -3051,8 +3019,16 @@
                                               VarRealpath, NULL);
                            cp = tstr + 2;
                            termc = *cp;
-                       } else if (tstr[1] == 'u' || tstr[1] == 'l') {
-                           newStr = VarChangeCase(nstr, (tstr[1] == 'u'));
+                       } else if (tstr[1] == 'u') {
+                           char *dp = bmake_strdup(nstr);
+                           for (newStr = dp; *dp; dp++)
+                               *dp = toupper((unsigned char)*dp);
+                           cp = tstr + 2;
+                           termc = *cp;
+                       } else if (tstr[1] == 'l') {
+                           char *dp = bmake_strdup(nstr);
+                           for (newStr = dp; *dp; dp++)
+                               *dp = tolower((unsigned char)*dp);
                            cp = tstr + 2;
                            termc = *cp;
                        } else if (tstr[1] == 'W' || tstr[1] == 'w') {



Home | Main Index | Thread Index | Old Index