[#1147] Copying RVALUE — why the lucky stiff <ruby-core@...>

Hello, everyone. Hope you are all doing well.

18 messages 2003/06/17
[#1155] Re: Copying RVALUE — matz@... (Yukihiro Matsumoto) 2003/06/20

Hi,

[#1157] Re: Copying RVALUE — why the lucky stiff <ruby-core@...> 2003/06/20

Yukihiro Matsumoto (matz@ruby-lang.org) wrote:

[#1173] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...>

Hi, I'm new to this mailing list so I don't know the procedure for

15 messages 2003/06/22
[#1174] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — nobu.nokada@... 2003/06/22

Hi,

[#1175] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...> 2003/06/22

On Sun, 2003-06-22 at 05:36, nobu.nokada@softhome.net wrote:

[#1176] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — nobu.nokada@... 2003/06/22

Hi,

[#1193] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...> 2003/06/25

On Sun, 2003-06-22 at 07:41, nobu.nokada@softhome.net wrote:

[#1177] Re: In 1.8.0 nil.to_s is not the same as "" — ts <decoux@...>

14 messages 2003/06/22

Re: [Patch] class.c code cleanup (rb_class_*_instance_methods)

From: Matthew Dempsky <jivera@...>
Date: 2003-06-26 04:17:12 UTC
List: ruby-core #1199
On Wed, 2003-06-25 at 17:54, nobu.nokada@softhome.net wrote:
> Warnings are emitted.

Ugh, what compile flags did you set to get these warnings?  They were
getting through fine when I used gcc -Wall.

In your patch, recurse has the possibility of not being initialized and
it doesn't make sense to call rb_scan_args unconditionally if you're
only going to use the result and side-effects conditionally.  This patch
is basically the same as yours just recurse is initialized and the
rb_scan_args() call is only done when argc is non-zero.\
-jivera

Attachments (1)

class.patch (1.66 KB, text/x-diff)
--- class-cvs.c	2003-06-25 23:10:30.000000000 -0500
+++ class.c	2003-06-25 23:09:27.000000000 -0500
@@ -529,18 +529,32 @@
 }
 
 static VALUE
-method_list(mod, recur, func)
+class_instance_method_list(argc, argv, mod, func)
+    int argc;
+    VALUE *argv;
     VALUE mod;
-    int recur;
-    int (*func)();
+    int (*func) _((ID, long, VALUE));
 {
+    VALUE ary;
+    int recurse = Qtrue;
     st_table *list;
-    VALUE klass, ary;
+
+    if (argc) {
+        VALUE recur;
+        rb_scan_args(argc, argv, "01", &recur);
+        recurse = RTEST(recur);
+    }
+#if RUBY_VERSION_CODE < 181
+    else {
+	rb_warn("%s: parameter will default to 'true' as of 1.8.1", rb_id2name(rb_frame_last_func()));
+        recurse = Qnil;
+    }
+#endif
 
     list = st_init_numtable();
-    for (klass = mod; klass; klass = RCLASS(klass)->super) {
-	st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
-	if (!recur) break;
+    for (; mod; mod = RCLASS(mod)->super) {
+        st_foreach(RCLASS(mod)->m_tbl, method_entry, (st_data_t)list);
+        if (!recurse) break;
     }
     ary = rb_ary_new();
     st_foreach(list, func, ary);
@@ -549,26 +563,6 @@
     return ary;
 }
 
-static VALUE
-class_instance_method_list(argc, argv, mod, func)
-    int argc;
-    VALUE *argv;
-    VALUE mod;
-    void (*func)();
-{
-    VALUE recur;
-
-    rb_scan_args(argc, argv, "01", &recur);
-    if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
-	rb_warn("%s: parameter will default to 'true' as of 1.8.1", rb_id2name(rb_frame_last_func()));
-#else
-	recur = Qtrue;
-#endif
-    }
-    return method_list(mod, RTEST(recur), func);
-}
-
 VALUE
 rb_class_instance_methods(argc, argv, mod)
     int argc;

In This Thread