Commit b2cc52fa authored by Nick Mathewson's avatar Nick Mathewson 🐻
Browse files

Speed up eat_whitespace by a lot.

svn:r8434
parent 6b716fdf
......@@ -6,7 +6,7 @@ Changes in version 0.1.2.2-alpha - 2006-??-??
one.
o Minor Bugfixes
- Small performance improvements on parsing descriptors.
- Small performance improvements on parsing descriptors (x2).
- Major performance descriptor on inserting descriptors; change
algorithm from O(n^2) to O(n).
- Make the common memory allocation path faster on machines where
......
......@@ -413,17 +413,23 @@ eat_whitespace(const char *s)
{
tor_assert(s);
while (TOR_ISSPACE(*s) || *s == '#') {
while (TOR_ISSPACE(*s))
s++;
if (*s == '#') { /* read to a \n or \0 */
while (1) {
switch (*s) {
case '\0':
default:
return s;
case ' ':
case '\t':
case '\n':
case '\r':
++s;
break;
case '#':
++s;
while (*s && *s != '\n')
s++;
if (!*s)
return s;
++s;
}
}
return s;
}
/** Return a pointer to the first char of s that is not a space or a tab,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment