ruby-changes:30628
From: nobu <ko1@a...>
Date: Tue, 27 Aug 2013 16:56:57 +0900 (JST)
Subject: [ruby-changes:30628] nobu:r42707 (trunk): enumerator.c: rb_check_funcall
nobu 2013-08-27 16:56:52 +0900 (Tue, 27 Aug 2013) New Revision: 42707 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42707 Log: enumerator.c: rb_check_funcall * enumerator.c (enumerator_size): use rb_check_funcall() instead of respond_to? and call. Modified files: trunk/ChangeLog trunk/enumerator.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42706) +++ ChangeLog (revision 42707) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Tue Aug 27 16:51:21 2013 Nobuyoshi Nakada <nobu@r...> +Tue Aug 27 16:56:50 2013 Nobuyoshi Nakada <nobu@r...> + + * enumerator.c (enumerator_size): use rb_check_funcall() instead of + respond_to? and call. * enumerator.c (enumerator_each): ensure that argument array size does not overflow at appending. Index: enumerator.c =================================================================== --- enumerator.c (revision 42706) +++ enumerator.c (revision 42707) @@ -1007,19 +1007,19 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1007 enumerator_size(VALUE obj) { struct enumerator *e = enumerator_ptr(obj); + int argc = 0; + const VALUE *argv = NULL; + VALUE size; if (e->size_fn) { return (*e->size_fn)(e->obj, e->args, obj); } - if (rb_respond_to(e->size, id_call)) { - if (e->args) { - int argc = (int)RARRAY_LEN(e->args); - VALUE *argv = RARRAY_PTR(e->args); - return rb_funcall2(e->size, id_call, argc, argv); - } else { - return rb_funcall(e->size, id_call, 0); - } + if (e->args) { + argc = (int)RARRAY_LEN(e->args); + argv = RARRAY_RAWPTR(e->args); } + size = rb_check_funcall(e->size, id_call, argc, argv); + if (size != Qundef) return size; return e->size; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/