diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-01-08 06:05:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-01-08 06:05:08 +0000 |
commit | 17065d47a68eaa6a854297b94e4d85d379b23f2d (patch) | |
tree | 670a5d87beb9be1833869225ce4722607327f4ba /numeric.c | |
parent | a89ac45548573342400a563b407f13a8d5b06841 (diff) |
* range.c (range_each): treat fixnums specially to boost.
* numeric.c (num_step): remove rb_scan_args() for small speedup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -850,11 +850,21 @@ num_step(argc, argv, from) { VALUE to, step; - if (rb_scan_args(argc, argv, "11", &to, &step) == 1) { + if (argc == 1) { + to = argv[0]; step = INT2FIX(1); } - else if (rb_equal(step, INT2FIX(0))) { - rb_raise(rb_eArgError, "step cannot be 0"); + else { + if (argc == 2) { + to = argv[0]; + step = argv[1]; + } + else { + rb_raise(rb_eArgError, "wrong number of arguments"); + } + if (rb_equal(step, INT2FIX(0))) { + rb_raise(rb_eArgError, "step cannot be 0"); + } } if (FIXNUM_P(from) && FIXNUM_P(to) && FIXNUM_P(step)) { |