[前][次][番号順一覧][スレッド一覧]

ruby-changes:25012

From: shugo <ko1@a...>
Date: Mon, 1 Oct 2012 22:58:00 +0900 (JST)
Subject: [ruby-changes:25012] shugo:r37064 (trunk): * eval.c (identify_hash_new): new function to create a new identity

shugo	2012-10-01 22:56:37 +0900 (Mon, 01 Oct 2012)

  New Revision: 37064

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37064

  Log:
    * 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().

  Modified files:
    trunk/ChangeLog
    trunk/eval.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37063)
+++ ChangeLog	(revision 37064)
@@ -1,3 +1,11 @@
+Mon Oct  1 22:54:02 2012  Shugo Maeda  <shugo@r...>
+
+	* 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@i...>
 
 	* configure.in (--with-opt-dir): Make this also work on DLDFLAGS
Index: eval.c
===================================================================
--- eval.c	(revision 37063)
+++ eval.c	(revision 37064)
@@ -1040,6 +1040,20 @@
     }
 }
 
+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 @@
     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 @@
     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 @@
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]