summaryrefslogtreecommitdiff
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
commit844a6890c6fb00a311af6c27bcac482c2086cc3a (patch)
tree9a350ac63f9d16c4e11c7e4cf1d4bdb2d190939d /hash.c
parent51bf0388aa1b9cf86af556104917a6a544152cf8 (diff)
downloadruby-844a6890c6fb00a311af6c27bcac482c2086cc3a.tar.gz
* 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: svn+ssh://ci.ruby-lang.org/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 5405410fd1..e80051e737 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;
}