ruby-changes:43180
From: nobu <ko1@a...>
Date: Thu, 2 Jun 2016 10:54:22 +0900 (JST)
Subject: [ruby-changes:43180] nobu:r55254 (trunk): ruby.h: reduce repeated calcuations
nobu 2016-06-02 10:54:17 +0900 (Thu, 02 Jun 2016) New Revision: 55254 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55254 Log: ruby.h: reduce repeated calcuations * include/ruby/ruby.h (rb_scan_args_{hash,block}_idx): reduce repeated index calcuations. * include/ruby/ruby.h (rb_scan_args_end_idx): unused right now. Modified files: trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 55253) +++ include/ruby/ruby.h (revision 55254) @@ -2293,7 +2293,8 @@ ALWAYS_INLINE(static int rb_scan_args_ha https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2293 static inline int rb_scan_args_hash_idx(const char *fmt) { - return (rb_scan_args_trail_idx(fmt)+rb_scan_args_trail_p(fmt)); + const int idx = rb_scan_args_trail_idx(fmt); + return idx+rb_scan_args_isdigit(fmt[idx]); } ALWAYS_INLINE(static int rb_scan_args_f_hash(const char *fmt)); @@ -2307,7 +2308,8 @@ ALWAYS_INLINE(static int rb_scan_args_bl https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2308 static inline int rb_scan_args_block_idx(const char *fmt) { - return (rb_scan_args_hash_idx(fmt)+rb_scan_args_f_hash(fmt)); + const int idx = rb_scan_args_hash_idx(fmt); + return idx+(fmt[idx]==':'); } ALWAYS_INLINE(static int rb_scan_args_f_block(const char *fmt)); @@ -2317,12 +2319,15 @@ rb_scan_args_f_block(const char *fmt) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2319 return (fmt[rb_scan_args_block_idx(fmt)]=='&'); } +# if 0 ALWAYS_INLINE(static int rb_scan_args_end_idx(const char *fmt)); static inline int rb_scan_args_end_idx(const char *fmt) { - return (rb_scan_args_block_idx(fmt)+rb_scan_args_f_block(fmt)); + const int idx = rb_scan_args_block_idx(fmt); + return idx+(fmt[idx]=='&'); } +# endif # define rb_scan_args0(argc, argv, fmt, varc, vars) \ rb_scan_args_set(argc, argv, \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/