[or-cvs] stop wasting time doing a case insensitive comparison for e...

Roger Dingledine arma at seul.org
Wed Apr 6 20:25:24 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	dns.c 
Log Message:
stop wasting time doing a case insensitive comparison for every dns name
every time we do any lookup. canonicalize the names to lowercase and be
done with it.


Index: dns.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -d -r1.146 -r1.147
--- dns.c	6 Apr 2005 06:43:21 -0000	1.146
+++ dns.c	6 Apr 2005 20:25:21 -0000	1.147
@@ -81,7 +81,7 @@
 static int compare_cached_resolves(struct cached_resolve *a,
                                    struct cached_resolve *b) {
   /* make this smarter one day? */
-  return strncasecmp(a->address, b->address, MAX_ADDRESSLEN);
+  return strncmp(a->address, b->address, MAX_ADDRESSLEN);
 }
 
 SPLAY_PROTOTYPE(cache_tree, cached_resolve, node, compare_cached_resolves);
@@ -246,6 +246,9 @@
    * resolves in the tree. */
   purge_expired_resolves(now);
 
+  /* lower-case exitconn->address, so it's in canonical form */
+  tor_strlower(exitconn->address);
+
   /* now check the tree to see if 'address' is already there. */
   strlcpy(search.address, exitconn->address, sizeof(search.address));
   resolve = SPLAY_FIND(cache_tree, &cache_root, &search);



More information about the tor-commits mailing list