From 7b0ec744bc8afa691873f97cfb6a3b7822376d7b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 19 Sep 2006 22:20:09 +0000 Subject: Switch routerlist.c to using memcmp on digests rather than crypto_pk_cmp_keys(); speed up find_whitespace a lot (8x for me) by using a switch statement. This should speed parsing a lot of routers at once by a lot. svn:r8430 --- src/common/util.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/common') diff --git a/src/common/util.c b/src/common/util.c index 8bd1f2aec..264bd0b74 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -434,11 +434,20 @@ const char * find_whitespace(const char *s) { /* tor_assert(s); */ - - while (*s && !TOR_ISSPACE(*s) && *s != '#') - s++; - - return s; + while (1) { + switch (*s) + { + case '\0': + case '#': + case ' ': + case '\r': + case '\n': + case '\t': + return s; + default: + ++s; + } + } } /** Return true iff the 'len' bytes at 'mem' are all zero. */ -- cgit v1.2.3