summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-27 15:56:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-27 15:56:14 +0000
commit8bd833f38e2e36f0f7eb5b01ff6363dcfeda1125 (patch)
tree9a350ac63f9d16c4e11c7e4cf1d4bdb2d190939d /hash.c
parente837f27e7bb08a416aba5e5dee8d2774eb372205 (diff)
downloadruby-8bd833f38e2e36f0f7eb5b01ff6363dcfeda1125.tar.gz
ruby-8bd833f38e2e36f0f7eb5b01ff6363dcfeda1125.tar.xz
ruby-8bd833f38e2e36f0f7eb5b01ff6363dcfeda1125.zip
* st.c (st_insert2): new function with processing new key,
e.g. copy. * hash.c (rb_hash_aset): use st_insert2() to reduce redundant st_lookup calls. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 5405410fd..e80051e73 100644
--- a/hash.c
+++ b/hash.c
@@ -1015,12 +1015,11 @@ VALUE
rb_hash_aset(VALUE hash, VALUE key, VALUE val)
{
rb_hash_modify(hash);
- if (RHASH(hash)->ntbl->type == &identhash ||
- rb_obj_class(key) != rb_cString || st_lookup(RHASH(hash)->ntbl, key, 0)) {
+ if (RHASH(hash)->ntbl->type == &identhash || rb_obj_class(key) != rb_cString) {
st_insert(RHASH(hash)->ntbl, key, val);
}
else {
- st_add_direct(RHASH(hash)->ntbl, rb_str_new4(key), val);
+ st_insert2(RHASH(hash)->ntbl, key, val, rb_str_new4);
}
return val;
}