]> granicus.if.org Git - apache/commitdiff
write these in terms of strchr and strrchr so the compiler can possibly use
authorGreg Stein <gstein@apache.org>
Mon, 12 Feb 2001 02:39:24 +0000 (02:39 +0000)
committerGreg Stein <gstein@apache.org>
Mon, 12 Feb 2001 02:39:24 +0000 (02:39 +0000)
builtin, optimized functions.
[ they're stupid functions, but what the hell ]

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88101 13f79535-47bb-0310-9956-ffa450edef68

server/util.c

index 29d61dbe53cb24a75494a9a1fc1d3f6c178a2abb..a8d4ff2adb5165ed073258a1d06991fc6804057c 100644 (file)
@@ -1720,24 +1720,20 @@ AP_DECLARE(int) ap_is_url(const char *u)
 
 AP_DECLARE(int) ap_ind(const char *s, char c)
 {
-    register int x;
-
-    for (x = 0; s[x]; x++)
-       if (s[x] == c)
-           return x;
+    const char *p = ap_strchr_c(s, c);
 
-    return -1;
+    if (p == NULL)
+        return -1;
+    return p - s;
 }
 
 AP_DECLARE(int) ap_rind(const char *s, char c)
 {
-    register int x;
-
-    for (x = strlen(s) - 1; x != -1; x--)
-       if (s[x] == c)
-           return x;
+    const char *p = ap_strrchr_c(s, c);
 
-    return -1;
+    if (p == NULL)
+        return -1;
+    return p - s;
 }
 
 AP_DECLARE(void) ap_str_tolower(char *str)