From: Matthew Dempsky Date: 2003-06-26T13:54:02+09:00 Subject: Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) --=-mJ4HC6hZwzi1AJRjAA67 Content-Type: text/plain Content-Transfer-Encoding: 7bit Ack, the recurse = Qnil line should acually be recurse = Qfalse... patch resubmitted for convenience. (Eh, my quick little code fix is turning out to be a lot more complicated than I was originally expecting... :/) -jivera --=-mJ4HC6hZwzi1AJRjAA67 Content-Disposition: attachment; filename=class.patch Content-Type: text/plain; name=class.patch; charset= Content-Transfer-Encoding: 7bit --- 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 = Qfalse; + } +#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; --=-mJ4HC6hZwzi1AJRjAA67--