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

Speed up eat_whitespace by a lot.

svn:r8434
parent 6b716fdf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+14 −8
Original line number Diff line number Diff line
@@ -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 (*s && *s != '\n')
        s++;
      if (!*s)
  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;
    }
  }
  return s;
}

/** Return a pointer to the first char of s that is not a space or a tab,