diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-24 15:23:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-24 15:23:06 +0000 |
commit | b3d3d52cd69cb6ea3848e5eb5b4b18318850142f (patch) | |
tree | 55576e9e09c53ecd786f0798d54eeb0c2720e89a | |
parent | 4e612fa60865f86322f8bf01ce5ad78ffe870d1d (diff) | |
download | ruby-b3d3d52cd69cb6ea3848e5eb5b4b18318850142f.tar.gz |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | include/ruby/ruby.h | 21 |
2 files changed, 12 insertions, 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 diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index de61ced053..b7ee5db942 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -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 |