summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-06 07:49:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-06 07:49:24 +0000
commit98e65d9d921ec810bbae2233b80e865e76dd8502 (patch)
tree16ce055f3f2dfcedef55c4649e5eb3d7bf707040 /range.c
parent0cd28199e50039e9425f10b880c436d3ecacde0b (diff)
Prefer rb_check_arity when 0 or 1 arguments
Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/range.c b/range.c
index 9661feb7187..c30852e500f 100644
--- a/range.c
+++ b/range.c
@@ -397,12 +397,7 @@ range_step(int argc, VALUE *argv, VALUE range)
b = RANGE_BEG(range);
e = RANGE_END(range);
- if (argc == 0) {
- step = INT2FIX(1);
- }
- else {
- rb_scan_args(argc, argv, "01", &step);
- }
+ step = (!rb_check_arity(argc, 0, 1) ? INT2FIX(1) : argv[0]);
if (!rb_block_given_p()) {
if (rb_obj_is_kind_of(b, rb_cNumeric) && (NIL_P(e) || rb_obj_is_kind_of(e, rb_cNumeric))) {