summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-09-19 23:55:35 +0000
committerNick Mathewson <nickm@torproject.org>2006-09-19 23:55:35 +0000
commitb2cc52fa02d3a440f8969b6c616d5acc3c09e50f (patch)
treea32cba31682e85b0a5637980d4b2933599270658
parent6b716fdfb96f0dd746c948a8624dc90cec64d0c1 (diff)
downloadtor-b2cc52fa02d3a440f8969b6c616d5acc3c09e50f.tar.gz
tor-b2cc52fa02d3a440f8969b6c616d5acc3c09e50f.zip
Speed up eat_whitespace by a lot.
svn:r8434
-rw-r--r--ChangeLog2
-rw-r--r--src/common/util.c22
2 files changed, 15 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b2a7f7ebb..b3c8e865af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/src/common/util.c b/src/common/util.c
index d0f568486c..b572c3a745 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -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,