mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
6e01f9dfc6
Optimizes array operations by hoisting RARRAY_PTR macro calls outside loops to avoid repeated conditional checks (embed vs heap storage). Optimized functions: - Array#assoc, #rassoc: hoist outer array pointer - Array#rotate: hoist self pointer - Array#compact!: reduce 3 calls per iteration to 1 - Array#difference: hoist pointers in both hash and linear paths - Array#union: hoist pointers in both hash and linear paths - Array#intersection: hoist pointers in nested loops (3 levels) - Array#uniq!: reduce O(n²) to O(n) pointer calls in linear path - Array#disjoint?: hoist both array pointers in nested loop Performance impact: 20-90% reduction in pointer dereference overhead depending on array size and operation complexity. Co-authored-by: Claude <noreply@anthropic.com>