[svn:parrot] r39684 - branches/tt761_keys_revamp/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Sun Jun 21 09:39:33 UTC 2009


Author: bacek
Date: Sun Jun 21 09:39:33 2009
New Revision: 39684
URL: https://trac.parrot.org/parrot/changeset/39684

Log:
[pmc] Strip "old" iterators support from Hash.

Modified:
   branches/tt761_keys_revamp/src/pmc/hash.pmc

Modified: branches/tt761_keys_revamp/src/pmc/hash.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/hash.pmc	Sun Jun 21 09:39:08 2009	(r39683)
+++ branches/tt761_keys_revamp/src/pmc/hash.pmc	Sun Jun 21 09:39:33 2009	(r39684)
@@ -305,19 +305,10 @@
         PMC        *nextkey;
         const Hash * const hash = (Hash *)SELF.get_pointer();
 
-        /* called from iterator with an integer idx in key */
-        if ((PObj_get_FLAGS(key) & KEY_type_FLAGS) == KEY_hash_iterator_FLAGS) {
-
-            /* check if we really have Hash_key_type_int */
-            if (hash->key_type == Hash_key_type_int) {
-                void *idx = parrot_hash_get_idx(INTERP, hash, key);
-                return (INTVAL)idx;
-            }
-            else {
-                const STRING * const s =
-                    (STRING *)parrot_hash_get_idx(INTERP, hash, key);
-                return Parrot_str_to_int(INTERP, s);
-            }
+        /* called from iterator */
+        if (VTABLE_type(INTERP, key) == enum_class_HashIteratorKey) {
+            PMC *val = (PMC*)PARROT_HASHITERATORKEY(key)->bucket->value;
+            return VTABLE_get_string(INTERP, val);
         }
 
         keystr  = make_ro_hash_key(INTERP, key);
@@ -514,16 +505,6 @@
             return VTABLE_get_string(INTERP, val);
         }
 
-        if ((PObj_get_FLAGS(key) & KEY_type_FLAGS) == KEY_hash_iterator_FLAGS) {
-            /* called from iterator with an integer idx in key */
-            if (hash->key_type == Hash_key_type_int) {
-                void  *idx = parrot_hash_get_idx(INTERP, hash, key);
-                return Parrot_str_from_int(INTERP, (INTVAL)idx);
-            }
-
-            return (STRING *)parrot_hash_get_idx(INTERP, hash, key);
-        }
-
         keystr = make_ro_hash_key(INTERP, key);
         b      = parrot_hash_get_bucket(INTERP, hash, keystr);
 
@@ -625,26 +606,6 @@
             return (PMC*)PARROT_HASHITERATORKEY(key)->bucket->value;
         }
 
-        /* called from iterator with an integer idx in key */
-        if ((PObj_get_FLAGS(key) & KEY_type_FLAGS) == KEY_hash_iterator_FLAGS) {
-            PMC *result;
-
-            /* check if we really have Hash_key_type_int */
-            if (hash->key_type == Hash_key_type_int) {
-                void *idx           = parrot_hash_get_idx(INTERP, hash, key);
-                const INTVAL i      = (INTVAL)idx;
-                result              = pmc_new(INTERP, enum_class_Integer);
-                VTABLE_set_integer_native(INTERP, result, i);
-            }
-            else {
-                STRING *s = (STRING *)parrot_hash_get_idx(INTERP, hash, key);
-                result    = pmc_new(INTERP, enum_class_String);
-                VTABLE_set_string_native(INTERP, result, s);
-            }
-
-            return result;
-        }
-
         keystr = make_ro_hash_key(INTERP, key);
         b      = parrot_hash_get_bucket(INTERP, hash, keystr);
 


More information about the parrot-commits mailing list