stef...@apache.org wrote on Sun, Dec 25, 2011 at 21:40:37 -0000:
Author: stefan2
Date: Sun Dec 25 21:40:37 2011
New Revision: 1224647
URL: http://svn.apache.org/viewvc?rev=1224647&view=rev
Log:
Improve parsing speed of IDs and other structures by introducing
a wrapper around apr_strtok(). Since the latter has abysmal
performance if the number of separators is small, the new wrapper
uses its own implementation for the frequent case that there is
exactly one separator.
Replace calls to apr_strtok with calls to the new function if there
is the separator string may contain just one char (not always known
for pass-through parameters).
...
+char *
+svn_cstring_tokenize(const char *sep, char **str)
+{
+ char *token;
+ const char * next;
+ char csep;
+
+ /* let APR handle edge cases and multiple separators */
+ csep = *sep;
+ if (csep == '\0' || sep[2] != '\0')
+ return apr_strtok(NULL, sep, str);
+
Entirely possible that I'm not understanding, but shouldn't that be
sep[1] != '\0'
if you're trying to pass on the case where sep is > 1 character to
apr_strtok()?
In the exactly-1-char case:
sep[0] = <the char of interest>
sep[1] = 0
sep[2] = <unknown value>
-Travis