Remove unnecessary inline function `ary_elt`.
And the function does not conform the naming convention anyway.
MODIFY
include/mruby/array.h
include/mruby/array.h
@@ -276,15 +276,6 @@ MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
*/
MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len);
-static inline mrb_value
-ary_elt(mrb_value ary, mrb_int offset)
-{
- if (offset < 0 || RARRAY_LEN(ary) <= offset) {
- return mrb_nil_value();
- }
- return RARRAY_PTR(ary)[offset];
-}
-
MRB_END_DECL
#endif /* MRUBY_ARRAY_H */

MODIFY
mrbgems/mruby-array-ext/src/array.c
mrbgems/mruby-array-ext/src/array.c
@@ -127,11 +127,12 @@ mrb_ary_to_h(mrb_state *mrb, mrb_value ary)
hash = mrb_hash_new_capa(mrb, 0);
for (i = 0; i < RARRAY_LEN(ary); ++i) {
- v = mrb_check_array_type(mrb, RARRAY_PTR(ary)[i]);
+ mrb_value elt = RARRAY_PTR(ary)[i];
+ v = mrb_check_array_type(mrb, elt);
if (mrb_nil_p(v)) {
mrb_raisef(mrb, E_TYPE_ERROR, "wrong element type %S at %S (expected array)",
- mrb_str_new_cstr(mrb, mrb_obj_classname(mrb, ary_elt(ary, i))),
+ mrb_str_new_cstr(mrb, mrb_obj_classname(mrb, elt)),
mrb_fixnum_value(i)
);
}

MODIFY
src/array.c
src/array.c
@@ -1074,7 +1074,10 @@ mrb_ary_entry(mrb_value ary, mrb_int offset)
if (offset < 0) {
offset += RARRAY_LEN(ary);
}
- return ary_elt(ary, offset);
+ if (offset < 0 || RARRAY_LEN(ary) <= offset) {
+ return mrb_nil_value();
+ }
+ return RARRAY_PTR(ary)[offset];
}
static mrb_value

Remove unnecessary inline function `ary_elt`.

And the function does not conform the naming convention anyway.