[svn:parrot] r48852 - branches/hash_inlined_func/src

luben at svn.parrot.org luben at svn.parrot.org
Wed Sep 8 08:23:26 UTC 2010


Author: luben
Date: Wed Sep  8 08:23:25 2010
New Revision: 48852
URL: https://trac.parrot.org/parrot/changeset/48852

Log:
use some functions and macros defined in the new encoding refactor

Modified:
   branches/hash_inlined_func/src/hash.c

Modified: branches/hash_inlined_func/src/hash.c
==============================================================================
--- branches/hash_inlined_func/src/hash.c	Wed Sep  8 07:10:30 2010	(r48851)
+++ branches/hash_inlined_func/src/hash.c	Wed Sep  8 08:23:25 2010	(r48852)
@@ -198,15 +198,7 @@
     STRING const *s1 = (STRING const *)search_key;
     STRING const *s2 = (STRING const *)bucket_key;
 
-    if (s1->hashval != s2->hashval)
-        return 1;
-    if (s1->encoding == s2->encoding)
-        if (s1->bufused != s2->bufused)
-            return 1;
-        else
-            return memcmp(s1->strstart, s2->strstart, s1->bufused);
-    else
-        return STRING_compare(interp, s1, s2);
+    return STRING_equal(interp, s1, s2) == 0;
 }
 
 
@@ -1266,17 +1258,17 @@
 
             if (s == s2)
                 break;
-            /* manually inline hash_compare_string */
+            /* manually inline part of string_equal  */
             if (hashval == s2->hashval) {
-                if (s->encoding == s2->encoding) {
-                    if ((s->bufused == s2->bufused)
-                    && (memcmp(s->strstart, s2->strstart, s->bufused) == 0))
+                if (s->encoding == s2->encoding) 
+                    if ((STRING_byte_length(s) == STRING_byte_length(s2))
+                    && (memcmp(s->strstart, s2->strstart, STRING_byte_length(s)) == 0))
                         break;
-                }
                 else
-                    if (STRING_compare(interp, s, s2) == 0)
+                    if (STRING_equal(interp, s, s2))
                         break;
             }
+
             bucket = bucket->next;
         }
     }
@@ -1372,15 +1364,14 @@
             const STRING *s2 = (const STRING *)bucket->key;
             if (s == s2)
                 break;
-            /* manually inline hash_compare_string */
+            /* manually inline part of string_equal  */
             if (hashval == s2->hashval) {
-                if (s->encoding == s2->encoding) {
-                    if ((s->bufused == s2->bufused)
-                    && (memcmp(s->strstart, s2->strstart, s->bufused) == 0))
+                if (s->encoding == s2->encoding) 
+                    if ((STRING_byte_length(s) == STRING_byte_length(s2))
+                    && (memcmp(s->strstart, s2->strstart, STRING_byte_length(s)) == 0))
                         break;
-                }
                 else
-                    if (STRING_compare(interp, s, s2) == 0)
+                    if (STRING_equal(interp, s, s2))
                         break;
             }
             bucket = bucket->next;


More information about the parrot-commits mailing list