diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-27 15:56:14 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-27 15:56:14 +0000 |
commit | 844a6890c6fb00a311af6c27bcac482c2086cc3a (patch) | |
tree | 9a350ac63f9d16c4e11c7e4cf1d4bdb2d190939d /hash.c | |
parent | 51bf0388aa1b9cf86af556104917a6a544152cf8 (diff) | |
download | ruby-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.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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; } |