diff --git a/src/array.c b/src/array.c index fd043786a..a73e9a98a 100644 --- a/src/array.c +++ b/src/array.c @@ -1956,8 +1956,11 @@ mrb_ary_cmp(mrb_state *mrb, mrb_value ary1) if (mrb_obj_equal(mrb, ary1, ary2)) return mrb_fixnum_value(0); if (!mrb_array_p(ary2)) return mrb_nil_value(); + /* Hoist pointer retrieval outside loop to avoid repeated conditionals */ + mrb_value *ptr1 = RARRAY_PTR(ary1); + mrb_value *ptr2 = RARRAY_PTR(ary2); for (mrb_int i=0; i