diff options
author | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-27 05:28:55 +0000 |
---|---|---|
committer | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-27 05:28:55 +0000 |
commit | 0c3b3e9237e8fae4bdfd9e577b1f6275918e1abb (patch) | |
tree | 6e17d836d0973f47364e275a7e3894c49f16dddc /hash.c | |
parent | 26e969182ba3ccc35e611800ece366b4b106c755 (diff) | |
download | ruby-0c3b3e9237e8fae4bdfd9e577b1f6275918e1abb.tar.gz |
* hash.c (hash_aset_str): Use rb_fstring() to de-duplicate hash string
keys. Patch by Eric Wong. [Bug #8998] [ruby-core:57727]
* test/ruby/test_hash.rb (class TestHash): test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1262,7 +1262,9 @@ static int hash_aset_str(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing) { if (!existing) { - *key = rb_str_new_frozen((VALUE)*key); + VALUE str = (VALUE)*key; + if (!OBJ_FROZEN(str)) + *key = rb_fstring((VALUE)*key); } return hash_aset(key, val, arg, existing); } |