ruby-changes:43076
From: nobu <ko1@a...>
Date: Wed, 25 May 2016 00:23:10 +0900 (JST)
Subject: [ruby-changes:43076] nobu:r55150 (trunk): ruby.h: optimize rb_scan_args_set
nobu 2016-05-25 00:23:06 +0900 (Wed, 25 May 2016) New Revision: 55150 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55150 Log: 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. Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 55149) +++ include/ruby/ruby.h (revision 55150) @@ -2245,16 +2245,9 @@ rb_scan_args_set(int argc, const VALUE * https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2245 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 * https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2269 } } } + + 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 * https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2324 } } - if (argi < argc) { - argc_error: - rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt); - } - return argc; } #endif Index: ChangeLog =================================================================== --- ChangeLog (revision 55149) +++ ChangeLog (revision 55150) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed May 25 00:23:05 2016 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * configure.in (XCFLAGS): merge flags only for ruby itself from -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/