summaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-08 06:05:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-08 06:05:08 +0000
commite1025c52b09808558ffdc22dbff5778944ff66f7 (patch)
tree670a5d87beb9be1833869225ce4722607327f4ba /numeric.c
parent19001e8ee95d8b4835748da8f3b3587202ad5f10 (diff)
downloadruby-e1025c52b09808558ffdc22dbff5778944ff66f7.tar.gz
ruby-e1025c52b09808558ffdc22dbff5778944ff66f7.tar.xz
ruby-e1025c52b09808558ffdc22dbff5778944ff66f7.zip
* range.c (range_each): treat fixnums specially to boost.
* numeric.c (num_step): remove rb_scan_args() for small speedup. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/numeric.c b/numeric.c
index 28061cad5..04c59f4ae 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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)) {