diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-12 15:25:58 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-12 15:25:58 +0000 |
commit | 3d59a9af909af102317335de081b1c07eaf6d0e4 (patch) | |
tree | 3d0173cf8af5949767e7c3e6375d188e3277e530 /internal.h | |
parent | 1d84fb58235ebcfa474a56e158a71fa7a1db5caf (diff) | |
download | ruby-3d59a9af909af102317335de081b1c07eaf6d0e4.tar.gz |
vm_insnhelper.c: inline array aref with integer
internal.h: define inlinable rb_ary_entry_internal.
array.c: use rb_ary_entry_internal.
* Benchmark
ruby --jit mame/optcarrot/bin/optcarrot --benchmark mame/optcarrot/examples/Lan_Master.nes
** Before
checksum: 59662
fps: 58.095175012159686
** After
fps: 59.874751599221526
checksum: 59662
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal.h b/internal.h index 88a1f9210e..3ca1352505 100644 --- a/internal.h +++ b/internal.h @@ -1093,6 +1093,22 @@ VALUE rb_check_to_array(VALUE ary); }) #endif +static inline VALUE +rb_ary_entry_internal(VALUE ary, long offset) +{ + long len = RARRAY_LEN(ary); + const VALUE *ptr = RARRAY_CONST_PTR(ary); + if (len == 0) return Qnil; + if (offset < 0) { + offset += len; + if (offset < 0) return Qnil; + } + else if (len <= offset) { + return Qnil; + } + return ptr[offset]; +} + /* bignum.c */ extern const char ruby_digitmap[]; double rb_big_fdiv_double(VALUE x, VALUE y); |