mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
ea5de2b8da
Moved Array#& (set intersection) implementation from Ruby to C to improve memory usage and performance. The C implementation uses hash-based deduplication for large arrays (>16 elements) and linear search for smaller arrays, following the same hybrid pattern as Array#| and Array#-. Key improvements: - Hash-based approach uses mrb_hash_delete_key() for proper deduplication - Linear search approach checks result array to ensure uniqueness - Maintains order preservation from the first array - Eliminates temporary object creation in Ruby implementation Added comprehensive test coverage for both small and large array scenarios, including edge cases like no intersection, complete intersection, and duplicate handling. Co-authored-by: Atlassian Rovo Dev