]> sjero.net Git - wget/commitdiff
[svn] Made strpbrk_or_eos a macro under Gcc.
authorhniksic <devnull@localhost>
Mon, 15 Sep 2003 10:47:46 +0000 (03:47 -0700)
committerhniksic <devnull@localhost>
Mon, 15 Sep 2003 10:47:46 +0000 (03:47 -0700)
src/ChangeLog
src/url.c

index 8d35838385e62bb8a146a190e7de5d4381549608..643d0ba1c4beff1cbc949676dcb991160ae3640a 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-15  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * url.c (strpbrk_or_eos): Implement as a macro under Gcc.
+
 2003-09-15  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * cookies.c (parse_set_cookies): Allow trailing space in
index 3a8feb70e28f646d3cd56f6d3fa95bf0a60cfe4d..9776cc3e0dbb8ab194e748e0f827ce5d04fd057f 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -616,7 +616,26 @@ static void parse_path PARAMS ((const char *, char **, char **));
 
 /* Like strpbrk, with the exception that it returns the pointer to the
    terminating zero (end-of-string aka "eos") if no matching character
-   is found.  */
+   is found.
+
+   Although I normally balk at Gcc-specific optimizations, it probably
+   makes sense here: glibc has optimizations that detect strpbrk being
+   called with literal string as ACCEPT and inline the search.  That
+   optimization is defeated if strpbrk is hidden within the call to
+   another function.  (And no, making strpbrk_or_eos inline doesn't
+   help because the check for literal accept is in the
+   preprocessor.)  */
+
+#ifdef __GNUC__
+
+#define strpbrk_or_eos(s, accept) ({           \
+  char *SOE_p = strpbrk (s, accept);           \
+  if (!SOE_p)                                  \
+    SOE_p = (char *)s + strlen (s);            \
+  SOE_p;                                       \
+})
+
+#else  /* not __GNUC__ */
 
 static char *
 strpbrk_or_eos (const char *s, const char *accept)
@@ -626,6 +645,7 @@ strpbrk_or_eos (const char *s, const char *accept)
     p = (char *)s + strlen (s);
   return p;
 }
+#endif
 
 /* Turn STR into lowercase; return non-zero if a character was
    actually changed. */