fix the simple hash finding function and use it
authorZack Rusin <zack@tungstengraphics.com>
Wed, 23 Apr 2008 17:32:41 +0000 (13:32 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 23 Apr 2008 17:32:41 +0000 (13:32 -0400)
src/gallium/auxiliary/cso_cache/cso_cache.c
src/gallium/auxiliary/draw/draw_pt_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch.c

index 63464e070581b17dd4b3367c0ccad608846a61d0..096875807bed8384ee185fa831a659f794b6b3f4 100644 (file)
@@ -255,9 +255,9 @@ void *cso_hash_find_data_from_template( struct cso_hash *hash,
    while (!cso_hash_iter_is_null(iter)) {
       void *iter_data = cso_hash_iter_data(iter);
       if (!memcmp(iter_data, templ, size)) {
-        /* Return the payload: 
+        /* We found a match
          */
-         return (unsigned char *)iter_data + size;
+         return iter_data;
       }
       iter = cso_hash_iter_next(iter);
    }
index d35329aba0f879052205e2a3f729b4d122af43f0..92ad8f70497fbd1c535f8abfa52a459d2aa667d1 100644 (file)
@@ -65,16 +65,14 @@ static struct translate *cached_translate(struct pt_emit *emit,
                                           struct translate_key *key)
 {
    unsigned hash_key = create_key(key);
-   struct cso_hash_iter iter = cso_hash_find(emit->hash, hash_key);
-   struct translate *translate = 0;
-
-   if (cso_hash_iter_is_null(iter)) {
+   struct translate *translate = (struct translate*)
+      cso_hash_find_data_from_template(emit->hash,
+                                       hash_key,
+                                       key, sizeof(*key));
+   if (!translate) {
+      /* create/insert */
       translate = translate_create(key);
       cso_hash_insert(emit->hash, hash_key, translate);
-      /*debug_printf("\tCREATED with %d\n", hash_key);*/
-   } else {
-      translate = cso_hash_iter_data(iter);
-      /*debug_printf("\tOK with %d\n", hash_key);*/
    }
 
    return translate;
index a8d4be5b64b95bb1eb24e1e60527f805ada8b8d8..013d16e1bcc0c328455bbf29ae37f7c3036087a9 100644 (file)
@@ -67,19 +67,10 @@ static struct translate *cached_translate(struct pt_fetch *fetch,
                                           struct translate_key *key)
 {
    unsigned hash_key = create_key(key);
-   struct cso_hash_iter iter = cso_hash_find(fetch->hash, hash_key);
-   struct translate *translate = 0;
-
-   while (!cso_hash_iter_is_null(iter)) {
-      void *iter_data = cso_hash_iter_data(iter);
-      if (memcmp(iter_data, key, sizeof(*key)) == 0) {
-         /* found */
-         translate = cso_hash_iter_data(iter);
-         break;
-      }
-      iter = cso_hash_iter_next(iter);
-      /*debug_printf("\tOK with %d\n", hash_key);*/
-   }
+   struct translate *translate = (struct translate*)
+      cso_hash_find_data_from_template(fetch->hash,
+                                       hash_key,
+                                       key, sizeof(*key));
 
    if (!translate) {
       /* create/insert */