summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-24 15:23:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-24 15:23:06 +0000
commitb3d3d52cd69cb6ea3848e5eb5b4b18318850142f (patch)
tree55576e9e09c53ecd786f0798d54eeb0c2720e89a /include
parent4e612fa60865f86322f8bf01ce5ad78ffe870d1d (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/ruby/ruby.h21
1 files changed, 6 insertions, 15 deletions
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