]> granicus.if.org Git - php/commitdiff
Slight optimization of php_strtoupper & php_strtoupper functions.
authorIlia Alshanetsky <iliaa@php.net>
Sun, 25 Aug 2002 19:08:07 +0000 (19:08 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 25 Aug 2002 19:08:07 +0000 (19:08 +0000)
ext/standard/string.c

index 68b3de8e84bb6ccbfb462f375b546c803d014e5a..8eb1167b8fd5d42131a23772dc3ce0177a19ab75 100644 (file)
@@ -942,14 +942,14 @@ restore:
  */
 PHPAPI char *php_strtoupper(char *s, size_t len)
 {
-       char *c;
-       int ch;
-       size_t i;
-
+       char *c, *e;
+       
        c = s;
-       for (i=0; i<len; i++) {
-               ch = toupper((unsigned char)*c);
-               *c++ = ch;
+       e = c+len;
+
+       while (c<e) {
+               *c = toupper(*c);
+               c++;
        }
        return s;
 }
@@ -976,14 +976,14 @@ PHP_FUNCTION(strtoupper)
  */
 PHPAPI char *php_strtolower(char *s, size_t len)
 {
-       register int ch;
-       char *c;
-       size_t i;
-
+       char *c, *e;
+       
        c = s;
-       for (i=0; i<len; i++) {
-               ch = tolower((unsigned char)*c);
-               *c++ = ch;
+       e = c+len;
+
+       while (c<e) {
+               *c = tolower(*c);
+               c++;
        }
        return s;
 }