aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
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 /src/common/util.c
parent6b716fdfb96f0dd746c948a8624dc90cec64d0c1 (diff)
downloadtor-b2cc52fa02d3a440f8969b6c616d5acc3c09e50f.tar
tor-b2cc52fa02d3a440f8969b6c616d5acc3c09e50f.tar.gz
Speed up eat_whitespace by a lot.
svn:r8434
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/common/util.c b/src/common/util.c
index d0f568486..b572c3a74 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,