[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8430: Switch routerlist.c to using memcmp on digests rather than c (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2006-09-19 18:20:09 -0400 (Tue, 19 Sep 2006)
New Revision: 8430

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/common/util.c
   tor/trunk/src/or/routerlist.c
Log:
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.

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-09-19 21:37:03 UTC (rev 8429)
+++ tor/trunk/ChangeLog	2006-09-19 22:20:09 UTC (rev 8430)
@@ -1,3 +1,9 @@
+Changes in version 0.1.2.2-alpha - 2006-??-??
+
+  o Minor Bugfixes
+    - Small performance improvements on parsing and inserting
+      descriptors.
+
 Changes in version 0.1.2.1-alpha - 2006-08-27
   o Major features:
     - Add "eventdns" async dns library from Adam Langley, tweaked to

Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c	2006-09-19 21:37:03 UTC (rev 8429)
+++ tor/trunk/src/common/util.c	2006-09-19 22:20:09 UTC (rev 8430)
@@ -434,11 +434,20 @@
 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. */

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2006-09-19 21:37:03 UTC (rev 8429)
+++ tor/trunk/src/or/routerlist.c	2006-09-19 22:20:09 UTC (rev 8430)
@@ -1674,7 +1674,8 @@
     routerinfo_t *old_router = smartlist_get(routerlist->routers, i);
     /* XXXX This might be a slow point; can't we just look up in one of the
      * digestmaps? -NM */
-    if (!crypto_pk_cmp_keys(router->identity_pkey,old_router->identity_pkey)) {
+    if (!memcmp(router->cache_info.identity_digest,
+                old_router->cache_info.identity_digest, DIGEST_LEN)) {
       if (router->cache_info.published_on <=
           old_router->cache_info.published_on) {
         /* Same key, but old */