mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
26e969182b
commit
0c3b3e9237
3 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Nov 27 14:24:55 2013 Aman Gupta <ruby@tmm1.net>
|
||||
|
||||
* 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.
|
||||
|
||||
Wed Nov 27 10:39:39 2013 Aman Gupta <ruby@tmm1.net>
|
||||
|
||||
* gc.c: Rename rb_heap_t members:
|
||||
|
|
4
hash.c
4
hash.c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -209,6 +209,12 @@ class TestHash < Test::Unit::TestCase
|
|||
assert_equal(256, h[z])
|
||||
end
|
||||
|
||||
def test_ASET_string
|
||||
a = {"ABC" => :t}
|
||||
b = {"ABC" => :t}
|
||||
assert_equal a.keys[0].object_id, b.keys[0].object_id
|
||||
end
|
||||
|
||||
def test_EQUAL # '=='
|
||||
h1 = @cls[ "a" => 1, "c" => 2 ]
|
||||
h2 = @cls[ "a" => 1, "c" => 2, 7 => 35 ]
|
||||
|
|
Loading…
Reference in a new issue