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

ruby-changes:38619

From: ko1 <ko1@a...>
Date: Mon, 1 Jun 2015 04:17:31 +0900 (JST)
Subject: [ruby-changes:38619] ko1:r50700 (trunk): * class.c (rb_class_has_methods): added to reduce depenedency

ko1	2015-06-01 04:17:18 +0900 (Mon, 01 Jun 2015)

  New Revision: 50700

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

  Log:
    * class.c (rb_class_has_methods): added to reduce depenedency
      to internal class data structure.
    * internal.h: ditto.
    * hash.c (has_extra_methods): use added function.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/hash.c
    trunk/internal.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50699)
+++ ChangeLog	(revision 50700)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun  1 04:15:42 2015  Koichi Sasada  <ko1@a...>
+
+	* class.c (rb_class_has_methods): added to reduce depenedency
+	  to internal class data structure.
+
+	* internal.h: ditto.
+
+	* hash.c (has_extra_methods): use added function.
+
 Mon Jun  1 04:11:48 2015  Koichi Sasada  <ko1@a...>
 
 	* gc.c , gc.h (rb_obj_info): export obj_info(VALUE) for debugging.
Index: class.c
===================================================================
--- class.c	(revision 50699)
+++ class.c	(revision 50700)
@@ -1985,6 +1985,13 @@ rb_get_kwargs(VALUE keyword_hash, const https://github.com/ruby/ruby/blob/trunk/class.c#L1985
 #undef extract_kwarg
 }
 
+int
+rb_class_has_methods(VALUE c)
+{
+    st_table *mtbl = RCLASS_M_TBL(c);
+    return mtbl && mtbl->num_entries ? TRUE : FALSE;
+}
+
 /*!
  * \}
  */
Index: hash.c
===================================================================
--- hash.c	(revision 50699)
+++ hash.c	(revision 50700)
@@ -37,8 +37,7 @@ has_extra_methods(VALUE klass) https://github.com/ruby/ruby/blob/trunk/hash.c#L37
     const VALUE base = rb_cHash;
     VALUE c = klass;
     while (c != base) {
-	st_table *mtbl = RCLASS_M_TBL(c);
-	if (mtbl && mtbl->num_entries) return klass;
+	if (rb_class_has_methods(c)) return klass;
 	c = RCLASS_SUPER(c);
     }
     return 0;
Index: internal.h
===================================================================
--- internal.h	(revision 50699)
+++ internal.h	(revision 50700)
@@ -667,6 +667,8 @@ VALUE rb_singleton_class_clone_and_attac https://github.com/ruby/ruby/blob/trunk/internal.h#L667
 VALUE rb_singleton_class_get(VALUE obj);
 void Init_class_hierarchy(void);
 
+int rb_class_has_methods(VALUE c);
+
 /* compar.c */
 VALUE rb_invcmp(VALUE, VALUE);
 

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

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