summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-01 13:56:37 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-01 13:56:37 +0000
commite56eb1b163eed2220fdde972b196c59a7c93edb0 (patch)
tree065577a9a8ed25009b0ce18ad2b79cabc25d7c96 /eval.c
parenta0f43fad5e37dd60d5f17bbe81e0e1d84e382147 (diff)
* 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
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 345dd83079..789ca37a03 100644
--- a/eval.c
+++ b/eval.c
@@ -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);