diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-21 22:35:43 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-21 22:35:43 +0000 |
commit | 58949cf8f3b5df1b410bc71c57b56c1c74ed9092 (patch) | |
tree | 140469c550385ed68641750f5724568b5937a7e2 | |
parent | 8d8a31bd7a4eaff794ec3db6f9292828cdc3d616 (diff) | |
download | ruby-58949cf8f3b5df1b410bc71c57b56c1c74ed9092.tar.gz |
* array.c (rb_ary_slice_bang): avoid call of rb_scan_args() unless
it's really necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 12 |
2 files changed, 14 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Fri May 22 05:09:43 2009 Yukihiro Matsumoto <matz@ruby-lang.org> + + * array.c (rb_ary_slice_bang): avoid call of rb_scan_args() unless + it's really necessary. + Thu May 21 22:17:52 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * template/id.h.tmpl, id.h (enum ruby_method_ids): added some IDs. @@ -2175,9 +2175,9 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) long pos, len, orig_len; rb_ary_modify_check(ary); - if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) { - pos = NUM2LONG(arg1); - len = NUM2LONG(arg2); + if (argc == 2) { + pos = NUM2LONG(argv[0]); + len = NUM2LONG(argv[1]); delete_pos_len: if (len < 0) return Qnil; orig_len = RARRAY_LEN(ary); @@ -2196,6 +2196,12 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) return arg2; } + if (argc != 1) { + /* error report */ + rb_scan_args(argc, argv, "11", NULL, NULL); + } + arg1 = argv[0]; + if (!FIXNUM_P(arg1)) { switch (rb_range_beg_len(arg1, &pos, &len, RARRAY_LEN(ary), 0)) { case Qtrue: |