diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-01 13:56:37 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-01 13:56:37 +0000 |
commit | e56eb1b163eed2220fdde972b196c59a7c93edb0 (patch) | |
tree | 065577a9a8ed25009b0ce18ad2b79cabc25d7c96 | |
parent | a0f43fad5e37dd60d5f17bbe81e0e1d84e382147 (diff) | |
download | ruby-e56eb1b163eed2220fdde972b196c59a7c93edb0.tar.gz |
* eval.c (identify_hash_new): new function to create a new identity
hash.
* eval.c (rb_overlay_module, rb_mod_using, rb_mod_refine): use
identify_hash_new().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | eval.c | 23 |
2 files changed, 25 insertions, 6 deletions
@@ -1,3 +1,11 @@ +Mon Oct 1 22:54:02 2012 Shugo Maeda <shugo@ruby-lang.org> + + * eval.c (identify_hash_new): new function to create a new identity + hash. + + * eval.c (rb_overlay_module, rb_mod_using, rb_mod_refine): use + identify_hash_new(). + Mon Oct 1 02:34:53 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (--with-opt-dir): Make this also work on DLDFLAGS @@ -1040,6 +1040,20 @@ void check_class_or_module(VALUE obj) } } +static VALUE +identity_hash_new() +{ + VALUE hash = rb_hash_new(); + + rb_funcall(hash, rb_intern("compare_by_identity"), 0); +#if 0 + /* FIXME: The following code hides hash, but causes "method `default' + * called on hidden T_HASH object" error. */ + RBASIC(hash)->klass = 0; +#endif + return hash; +} + void rb_overlay_module(NODE *cref, VALUE klass, VALUE module) { @@ -1048,8 +1062,7 @@ rb_overlay_module(NODE *cref, VALUE klass, VALUE module) check_class_or_module(klass); Check_Type(module, T_MODULE); if (NIL_P(cref->nd_omod)) { - cref->nd_omod = rb_hash_new(); - rb_funcall(cref->nd_omod, rb_intern("compare_by_identity"), 0); + cref->nd_omod = identity_hash_new(); } else { if (cref->flags & NODE_FL_CREF_OMOD_SHARED) { @@ -1121,8 +1134,7 @@ rb_mod_using(VALUE self, VALUE module) CONST_ID(id_using_modules, "__using_modules__"); using_modules = rb_attr_get(self, id_using_modules); if (NIL_P(using_modules)) { - using_modules = rb_hash_new(); - rb_funcall(using_modules, rb_intern("compare_by_identity"), 0); + using_modules = identity_hash_new(); rb_ivar_set(self, id_using_modules, using_modules); } rb_hash_aset(using_modules, module, Qtrue); @@ -1199,8 +1211,7 @@ rb_mod_refine(VALUE module, VALUE klass) CONST_ID(id_overlaid_modules, "__overlaid_modules__"); overlaid_modules = rb_attr_get(module, id_overlaid_modules); if (NIL_P(overlaid_modules)) { - overlaid_modules = rb_hash_new(); - rb_funcall(overlaid_modules, rb_intern("compare_by_identity"), 0); + overlaid_modules = identity_hash_new(); rb_ivar_set(module, id_overlaid_modules, overlaid_modules); } mod = rb_hash_aref(overlaid_modules, klass); |