ruby-changes:4197
From: ko1@a...
Date: Tue, 4 Mar 2008 19:15:00 +0900 (JST)
Subject: [ruby-changes:4197] matz - Ruby:r15687 (trunk): * hash.c (rb_hash_aset): should not copy key string when
matz 2008-03-04 19:14:40 +0900 (Tue, 04 Mar 2008) New Revision: 15687 Modified files: trunk/ChangeLog trunk/hash.c Log: * hash.c (rb_hash_aset): should not copy key string when compare_by_identity is set. [ruby-dev:33604] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/hash.c?r1=15687&r2=15686&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15687&r2=15686&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15686) +++ ChangeLog (revision 15687) @@ -1,3 +1,8 @@ +Tue Mar 4 19:10:43 2008 Yukihiro Matsumoto <matz@r...> + + * hash.c (rb_hash_aset): should not copy key string when + compare_by_identity is set. [ruby-dev:33604] + Tue Mar 4 16:29:06 2008 Yukihiro Matsumoto <matz@r...> * parse.y (parser_yylex): disallow non digits '0o' expression. Index: hash.c =================================================================== --- hash.c (revision 15686) +++ hash.c (revision 15687) @@ -103,6 +103,11 @@ rb_any_hash, }; +static const struct st_hash_type identhash = { + st_numcmp, + st_numhash, +}; + typedef int st_foreach_func(st_data_t, st_data_t, st_data_t); struct foreach_safe_arg { @@ -932,7 +937,8 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val) { rb_hash_modify(hash); - if (TYPE(key) != T_STRING || st_lookup(RHASH(hash)->ntbl, key, 0)) { + if (RHASH(hash)->ntbl->type == &identhash || + TYPE(key) != T_STRING || st_lookup(RHASH(hash)->ntbl, key, 0)) { st_insert(RHASH(hash)->ntbl, key, val); } else { @@ -1685,11 +1691,6 @@ return ary; } -static const struct st_hash_type identhash = { - st_numcmp, - st_numhash, -}; - /* * call-seq: * hsh.compare_by_identity => hsh -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/