From 610d4dd2e872c2c60b00d5cdb5549c0f8de33266 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 2 Jun 2016 01:54:17 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 64d33434bb..74f7b570c0 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2293,7 +2293,8 @@ ALWAYS_INLINE(static int rb_scan_args_hash_idx(const char *fmt)); 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_block_idx(const char *fmt)); 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) 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, \ -- cgit v1.2.3