diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-30 00:00:23 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-30 00:00:23 +0000 |
commit | 15caeb0fffa4e027677893a0c4892e57dcc90e9b (patch) | |
tree | 8964cc9540122e2f985d81c8879494ebad0b840d /st.c | |
parent | 70f9d38ab337f5517aeee97e23656bd219c9d140 (diff) | |
download | ruby-15caeb0fffa4e027677893a0c4892e57dcc90e9b.tar.gz |
hash literal deduplicates like Hash#[]=
From: Eric Wong <e@80x24.org>
* hash.c (rb_hash_key_str): new function
(hash_aset_str): use rb_hash_key_str
* internal.h: add rb_hash_key_str
* st.c (st_stringify): use rb_hash_key_str
* test/ruby/test_hash.rb (test_NEWHASH_fstring_key): dynamic key
[ruby-core:84554] [Feature #14258]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -2114,8 +2114,8 @@ st_rehash(st_table *tab) static st_data_t st_stringify(VALUE key) { - return (rb_obj_class(key) == rb_cString) ? - rb_str_new_frozen(key) : key; + return (rb_obj_class(key) == rb_cString && !RB_OBJ_FROZEN(key)) ? + rb_hash_key_str(key) : key; } static void |