[svn:parrot] r48315 - trunk/src

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Aug 4 12:23:12 UTC 2010


Author: NotFound
Date: Wed Aug  4 12:23:12 2010
New Revision: 48315
URL: https://trac.parrot.org/parrot/changeset/48315

Log:
let the compiler know that the key compare function does not change during a search

Modified:
   trunk/src/hash.c

Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c	Wed Aug  4 12:13:01 2010	(r48314)
+++ trunk/src/hash.c	Wed Aug  4 12:23:12 2010	(r48315)
@@ -1309,13 +1309,14 @@
     {
         const UINTVAL hashval = get_hash_val(interp, hash, key);
         HashBucket   *bucket  = hash->bucket_indices[hashval & hash->mask];
+        const hash_comp_fn compare = hash->compare;
 
         while (bucket) {
             /* key equality is always a match, so it's worth checking */
             if (bucket->key == key
 
             /* ... but the slower comparison is more accurate */
-            || ((hash->compare)(interp, key, bucket->key) == 0))
+            || ((compare)(interp, key, bucket->key) == 0))
                 return bucket;
             bucket = bucket->next;
         }
@@ -1390,6 +1391,7 @@
     ASSERT_ARGS(parrot_hash_put)
     const UINTVAL hashval = get_hash_val(interp, hash, key);
     HashBucket   *bucket  = hash->bucket_indices[hashval & hash->mask];
+    const hash_comp_fn compare = hash->compare;
 
     /* When the hash is constant, check that the key and value are also
      * constant. */
@@ -1409,7 +1411,7 @@
     /* See if we have an existing value for this key */
     while (bucket) {
         /* store hash_val or not */
-        if ((hash->compare)(interp, key, bucket->key) == 0)
+        if ((compare)(interp, key, bucket->key) == 0)
             break;
         bucket = bucket->next;
     }
@@ -1457,10 +1459,11 @@
     ASSERT_ARGS(parrot_hash_delete)
     HashBucket   *bucket;
     HashBucket   *prev    = NULL;
+    const hash_comp_fn compare = hash->compare;
     const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed) & hash->mask;
 
     for (bucket = hash->bucket_indices[hashval]; bucket; bucket = bucket->next) {
-        if ((hash->compare)(interp, key, bucket->key) == 0) {
+        if ((compare)(interp, key, bucket->key) == 0) {
 
             if (prev)
                 prev->next = bucket->next;


More information about the parrot-commits mailing list