mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby.h: optimize rb_scan_args_set
* include/ruby/ruby.h (rb_scan_args_set): check the arity after adjusting argc for an option hash, for optimization in simpler cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4e612fa608
commit
b3d3d52cd6
2 changed files with 12 additions and 15 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed May 25 00:23:05 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/ruby.h (rb_scan_args_set): check the arity after
|
||||
adjusting argc for an option hash, for optimization in simpler
|
||||
cases.
|
||||
|
||||
Wed May 25 00:21:52 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* configure.in (XCFLAGS): merge flags only for ruby itself from
|
||||
|
|
|
@ -2245,16 +2245,9 @@ rb_scan_args_set(int argc, const VALUE *argv,
|
|||
int f_var, int f_hash, int f_block,
|
||||
int varc, VALUE *vars[])
|
||||
{
|
||||
int i;
|
||||
int n_mand;
|
||||
VALUE *var;
|
||||
int argi = 0, vari = 0;
|
||||
VALUE hash = Qnil;
|
||||
|
||||
n_mand = n_lead + n_trail;
|
||||
|
||||
if (argc < n_mand)
|
||||
goto argc_error;
|
||||
int i, argi = 0, vari = 0;
|
||||
VALUE *var, hash = Qnil;
|
||||
const int n_mand = n_lead + n_trail;
|
||||
|
||||
/* capture an option hash - phase 1: pop */
|
||||
if (f_hash && n_mand < argc) {
|
||||
|
@ -2276,6 +2269,9 @@ rb_scan_args_set(int argc, const VALUE *argv,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
rb_check_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
|
||||
|
||||
/* capture leading mandatory arguments */
|
||||
for (i = n_lead; i-- > 0; ) {
|
||||
var = vars[vari++];
|
||||
|
@ -2328,11 +2324,6 @@ rb_scan_args_set(int argc, const VALUE *argv,
|
|||
}
|
||||
}
|
||||
|
||||
if (argi < argc) {
|
||||
argc_error:
|
||||
rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
|
||||
}
|
||||
|
||||
return argc;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue