[svn:parrot] r39709 - in branches/tt761_keys_revamp: include/parrot src

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Jun 22 11:22:26 UTC 2009


Author: bacek
Date: Mon Jun 22 11:22:25 2009
New Revision: 39709
URL: https://trac.parrot.org/parrot/changeset/39709

Log:
[core] Hash key can be null in case of INTVAL keys

Modified:
   branches/tt761_keys_revamp/include/parrot/hash.h
   branches/tt761_keys_revamp/include/parrot/pmc.h
   branches/tt761_keys_revamp/src/hash.c

Modified: branches/tt761_keys_revamp/include/parrot/hash.h
==============================================================================
--- branches/tt761_keys_revamp/include/parrot/hash.h	Mon Jun 22 11:21:54 2009	(r39708)
+++ branches/tt761_keys_revamp/include/parrot/hash.h	Mon Jun 22 11:22:25 2009	(r39709)
@@ -130,10 +130,9 @@
 PARROT_CAN_RETURN_NULL
 HashBucket * parrot_hash_get_bucket(PARROT_INTERP,
     ARGIN(const Hash *hash),
-    ARGIN(const void *key))
+    ARGIN_NULLOK(const void *key))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3);
+        __attribute__nonnull__(2);
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
@@ -151,11 +150,10 @@
 PARROT_CANNOT_RETURN_NULL
 HashBucket* parrot_hash_put(PARROT_INTERP,
     ARGMOD(Hash *hash),
-    ARGIN(void *key),
+    ARGIN_NULLOK(void *key),
     ARGIN_NULLOK(void *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
         FUNC_MODIFIES(*hash);
 
 PARROT_EXPORT
@@ -214,8 +212,9 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_PURE_FUNCTION
-size_t key_hash_int(SHIM_INTERP, ARGIN(const void *value), size_t seed)
-        __attribute__nonnull__(2);
+size_t key_hash_int(SHIM_INTERP,
+    ARGIN_NULLOK(const void *value),
+    size_t seed);
 
 void parrot_chash_destroy(PARROT_INTERP, ARGMOD(Hash *hash))
         __attribute__nonnull__(1)
@@ -263,16 +262,14 @@
     || PARROT_ASSERT_ARG(key)
 #define ASSERT_ARGS_parrot_hash_get_bucket __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(hash) \
-    || PARROT_ASSERT_ARG(key)
+    || PARROT_ASSERT_ARG(hash)
 #define ASSERT_ARGS_parrot_hash_get_idx __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(hash) \
     || PARROT_ASSERT_ARG(key)
 #define ASSERT_ARGS_parrot_hash_put __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(hash) \
-    || PARROT_ASSERT_ARG(key)
+    || PARROT_ASSERT_ARG(hash)
 #define ASSERT_ARGS_parrot_hash_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(hash)
 #define ASSERT_ARGS_parrot_hash_visit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -294,8 +291,7 @@
 #define ASSERT_ARGS_parrot_new_pointer_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_int_compare __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_key_hash_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(value)
+#define ASSERT_ARGS_key_hash_int __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_parrot_chash_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(hash)

Modified: branches/tt761_keys_revamp/include/parrot/pmc.h
==============================================================================
--- branches/tt761_keys_revamp/include/parrot/pmc.h	Mon Jun 22 11:21:54 2009	(r39708)
+++ branches/tt761_keys_revamp/include/parrot/pmc.h	Mon Jun 22 11:22:25 2009	(r39709)
@@ -80,7 +80,7 @@
 PMC * pmc_reuse(PARROT_INTERP,
     ARGIN(PMC *pmc),
     INTVAL new_type,
-    NULLOK(UINTVAL flags))
+    UINTVAL flags)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -103,7 +103,7 @@
     ARGIN(PMC *pmc),
     INTVAL new_type,
     ARGIN(PMC *init),
-    NULLOK(UINTVAL flags))
+    UINTVAL flags)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(4);

Modified: branches/tt761_keys_revamp/src/hash.c
==============================================================================
--- branches/tt761_keys_revamp/src/hash.c	Mon Jun 22 11:21:54 2009	(r39708)
+++ branches/tt761_keys_revamp/src/hash.c	Mon Jun 22 11:22:25 2009	(r39709)
@@ -322,13 +322,12 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_PURE_FUNCTION
 size_t
-key_hash_int(SHIM_INTERP, ARGIN(const void *value), size_t seed)
+key_hash_int(SHIM_INTERP, ARGIN_NULLOK(const void *value), size_t seed)
 {
     ASSERT_ARGS(key_hash_int)
     return (size_t)value ^ seed;
 }
 
-
 /*
 
 =item C<int int_compare(PARROT_INTERP, const void *a, const void *b)>
@@ -350,7 +349,6 @@
     return a != b;
 }
 
-
 /*
 
 =item C<void parrot_dump_hash(PARROT_INTERP, const Hash *hash)>
@@ -816,7 +814,7 @@
 
 =item C<Hash* parrot_new_hash(PARROT_INTERP)>
 
-Creates a new Parrot STRING hash in C<hptr>.
+Creates a new Parrot STRING hash.
 
 =cut
 
@@ -1188,7 +1186,7 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 HashBucket *
-parrot_hash_get_bucket(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN(const void *key))
+parrot_hash_get_bucket(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(const void *key))
 {
     ASSERT_ARGS(parrot_hash_get_bucket)
 
@@ -1204,7 +1202,7 @@
             HashBucket *bucket = hash->bs + i;
 
             /* the hash->compare cost is too high for this fast path */
-            if (bucket->key && bucket->key == key)
+            if (bucket->key == key)
                 return bucket;
         }
     }
@@ -1287,7 +1285,7 @@
 PARROT_IGNORABLE_RESULT
 PARROT_CANNOT_RETURN_NULL
 HashBucket*
-parrot_hash_put(PARROT_INTERP, ARGMOD(Hash *hash), ARGIN(void *key), ARGIN_NULLOK(void *value))
+parrot_hash_put(PARROT_INTERP, ARGMOD(Hash *hash), ARGIN_NULLOK(void *key), ARGIN_NULLOK(void *value))
 {
     ASSERT_ARGS(parrot_hash_put)
     const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed);


More information about the parrot-commits mailing list