[svn:parrot] r45862 - trunk/src/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Wed Apr 21 20:07:23 UTC 2010
Author: NotFound
Date: Wed Apr 21 20:07:22 2010
New Revision: 45862
URL: https://trac.parrot.org/parrot/changeset/45862
Log:
avoid creating and destroying a hash in Hash set_value_type method
Modified:
trunk/src/pmc/hash.pmc
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc Wed Apr 21 18:09:36 2010 (r45861)
+++ trunk/src/pmc/hash.pmc Wed Apr 21 20:07:22 2010 (r45862)
@@ -236,18 +236,15 @@
if (old_hash && old_hash->entry_type == type)
return;
- if (!old_hash)
- old_hash = parrot_new_hash(INTERP);
-
switch (type) {
case enum_type_INTVAL:
case enum_type_STRING:
case enum_type_PMC:
new_hash = parrot_create_hash(interp,
(PARROT_DATA_TYPE)type,
- old_hash->key_type,
- old_hash->compare,
- old_hash->hash_val);
+ old_hash ? old_hash->key_type : Hash_key_type_STRING,
+ old_hash ? old_hash->compare : STRING_compare,
+ old_hash ? old_hash->hash_val : (hash_hash_key_fn)key_hash_STRING);
break;
default:
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
@@ -257,7 +254,8 @@
PARROT_HASH(SELF)->hash = new_hash;
new_hash->container = SELF;
- parrot_hash_destroy(INTERP, old_hash);
+ if (old_hash)
+ parrot_hash_destroy(INTERP, old_hash);
}
METHOD get_value_type() {
More information about the parrot-commits
mailing list