+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
/* 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)
p = (char *)s + strlen (s);
return p;
}
+#endif
/* Turn STR into lowercase; return non-zero if a character was
actually changed. */