From de083a7ba1505713106ee3e0fb21051e613e2fe1 Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Mon, 12 Feb 2001 02:39:24 +0000 Subject: [PATCH] write these in terms of strchr and strrchr so the compiler can possibly use 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 | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/server/util.c b/server/util.c index 29d61dbe53c..a8d4ff2adb5 100644 --- a/server/util.c +++ b/server/util.c @@ -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) -- 2.47.2