]> err.no Git - varnish/commitdiff
Ditch HSH_Compare() and just check the digest with memcmp()
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 12 Jan 2009 13:51:33 +0000 (13:51 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 12 Jan 2009 13:51:33 +0000 (13:51 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3507 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/hash_classic.c
varnish-cache/bin/varnishd/hash_simple_list.c
varnish-cache/bin/varnishd/hash_slinger.h

index e8b28b4b34911c2b8e20b35054fcf58a3b0f8594..f95cd3f3cd1b00d2dac7e7c4c3ce5ed5eb80ab76 100644 (file)
@@ -143,36 +143,6 @@ HSH_Freestore(struct object *o)
        }
 }
 
-int
-HSH_Compare(const struct sess *sp, const struct objhead *oh)
-{
-       int i;
-       unsigned u, v;
-       const char *b;
-
-       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-       CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
-       CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
-       i = sp->lhashptr - oh->hashlen;
-       if (i)
-               return (i);
-       b = oh->hash;
-       for (u = 0; u < sp->ihashptr; u += 2) {
-               v = pdiff(sp->hashptr[u], sp->hashptr[u + 1]);
-               i = memcmp(sp->hashptr[u], b, v);
-               if (i)
-                       return (i);
-               b += v;
-               i = '#' - *b++;
-               if (i)
-                       return (i);
-       }
-       assert(*b == '\0');
-       b++;
-       assert(b == oh->hash + oh->hashlen);
-       return (0);
-}
-
 void
 HSH_Copy(const struct sess *sp, struct objhead *oh)
 {
index 9f2ee04a2fd5959fab41480ecd73d27eca4b50f1..5265235df09d887b28f0f5827b75dc90d734ee39 100644 (file)
@@ -132,15 +132,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
 
        Lck_Lock(&hp->mtx);
        VTAILQ_FOREACH(oh, &hp->head, hoh_list) {
-               if (sp->lhashptr < oh->hashlen)
-                       continue;
-               if (sp->lhashptr > oh->hashlen)
-                       break;
-               if (oh->hoh_digest < digest)
-                       continue;
-               if (oh->hoh_digest > digest)
-                       break;
-               i = HSH_Compare(sp, oh);
+               i = memcmp(oh->digest, noh->digest, sizeof oh->digest);
                if (i < 0)
                        continue;
                if (i > 0)
index 3a8a89ce242ec11fcc776788d66bcc7dee693f1c..bc604ff2631c5cc422e393f923931e6917d9f6eb 100644 (file)
@@ -75,7 +75,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
        CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
        Lck_Lock(&hsl_mtx);
        VTAILQ_FOREACH(oh, &hsl_head, hoh_list) {
-               i = HSH_Compare(sp, oh);
+               i = memcmp(oh->digest, noh->digest, sizeof oh->digest);
                if (i < 0)
                        continue;
                if (i > 0)
index d46830e159d0731978fe2e3cd3811815b33511d8..508bb69de9420a0dc00946f8d33bafcadeabbc06 100644 (file)
@@ -51,7 +51,6 @@ struct hash_slinger {
 /* cache_hash.c */
 void HSH_Prealloc(struct sess *sp);
 void HSH_Freestore(struct object *o);
-int HSH_Compare(const struct sess *sp, const struct objhead *o);
 void HSH_Copy(const struct sess *sp, struct objhead *o);
 struct object *HSH_Lookup(struct sess *sp);
 void HSH_Unbusy(const struct sess *sp);