summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-27 07:56:52 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-27 07:56:52 (GMT)
commit1af4196cdfead2daca292e8be3bb65e2e2478298 (patch)
treea7a4fa9d34109c57880657794987f400a82b82b3 /enumerator.c
parent9b4b5ad27c56ab713a95dfbfa84fdd74280fc9ca (diff)
enumerator.c: rb_check_funcall
* enumerator.c (enumerator_size): use rb_check_funcall() instead of respond_to? and call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/enumerator.c b/enumerator.c
index a83c053..6f3de86 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -1007,19 +1007,19 @@ static VALUE
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;
}