summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 01:09:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 01:09:44 +0000
commit09ef29a78fc960eaec1ecafbeef75b6eb29abf96 (patch)
treed1f37d8ed45b27706d1d91a2f14ed54fc54423de /enum.c
parentcfa6c55347d037b152a4b93a390c73dfee6dccbd (diff)
Prefer rb_check_arity when 0 or 1 arguments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/enum.c b/enum.c
index 4c10078..64eedc5 100644
--- a/enum.c
+++ b/enum.c
@@ -294,7 +294,7 @@ enum_find(int argc, VALUE *argv, VALUE obj)
struct MEMO *memo;
VALUE if_none;
- rb_scan_args(argc, argv, "01", &if_none);
+ if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
RETURN_ENUMERATOR(obj, argc, argv);
memo = MEMO_NEW(Qundef, 0, 0);
rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)memo);
@@ -1699,9 +1699,7 @@ enum_min(int argc, VALUE *argv, VALUE obj)
VALUE result;
VALUE num;
- rb_scan_args(argc, argv, "01", &num);
-
- if (!NIL_P(num))
+ if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0]))
return rb_nmin_run(obj, num, 0, 0, 0);
m->min = Qundef;
@@ -1793,9 +1791,7 @@ enum_max(int argc, VALUE *argv, VALUE obj)
VALUE result;
VALUE num;
- rb_scan_args(argc, argv, "01", &num);
-
- if (!NIL_P(num))
+ if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0]))
return rb_nmin_run(obj, num, 0, 1, 0);
m->max = Qundef;