diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-08-14 14:45:23 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-08-15 12:09:26 +0900 |
commit | ff30358d13d24d8202f2717c43700be70bdd49d3 (patch) | |
tree | 32757f4895a67fefcfb4830e40e2206a7ac388f7 /internal | |
parent | 72d0f2f0e0546a4c7c3b9ec85d3f67a36e9c5038 (diff) |
RARRAY_AREF: convert into an inline function
RARRAY_AREF has been a macro for reasons. We might not be able to
change that for public APIs, but why not relax the situation internally
to make it an inline function.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3419
Diffstat (limited to 'internal')
-rw-r--r-- | internal/array.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/array.h b/internal/array.h index 2e53d43c7d..c9f2b47145 100644 --- a/internal/array.h +++ b/internal/array.h @@ -100,4 +100,15 @@ RARY_TRANSIENT_UNSET(VALUE ary) }) #endif +#undef RARRAY_AREF +RBIMPL_ATTR_PURE_UNLESS_DEBUG() +RBIMPL_ATTR_ARTIFICIAL() +static inline VALUE +RARRAY_AREF(VALUE ary, long i) +{ + RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY); + + return RARRAY_CONST_PTR_TRANSIENT(ary)[i]; +} + #endif /* INTERNAL_ARRAY_H */ |