mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
8d8a31bd7a
commit
58949cf8f3
2 changed files with 14 additions and 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.
|
||||
|
|
12
array.c
12
array.c
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue