Module Name:    src
Committed By:   christos
Date:           Sun Feb 24 19:43:38 UTC 2013

Modified Files:
        src/usr.bin/make: var.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.172 src/usr.bin/make/var.c:1.173
--- src/usr.bin/make/var.c:1.172	Thu Nov 15 11:42:26 2012
+++ src/usr.bin/make/var.c	Sun Feb 24 14:43:37 2013
@@ -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 @@ static char *VarGetPattern(GNode *, Var_
 			   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 @@ VarHash(char *str)
    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 @@ ApplyModifiers(char *nstr, const char *t
 					       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') {

Reply via email to