diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-01-15 20:32:20 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-01-15 20:32:20 +0900 |
| commit | 11edc286d837f66b37433e7d51c8b8f500e1be84 (patch) | |
| tree | e5afcfa53807e17814da4b70b442515e0cf6fada /array.rb | |
| parent | 6afac93c5c7178c4d836e0ec2b4b3092373ca121 (diff) | |
Make `Array#map` and `Array#select` more tolerant
Only when YJIT is enabled, the redefinition of `Array#<<` affects
these methods.
Diffstat (limited to 'array.rb')
| -rw-r--r-- | array.rb | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -245,7 +245,8 @@ class Array value = nil result = Primitive.ary_sized_alloc while Primitive.cexpr!(%q{ ary_fetch_next(self, LOCAL_PTR(_i), LOCAL_PTR(value)) }) - result << yield(value) + value = yield(value) + Primitive.cexpr!(%q{ rb_ary_push(result, value) }) end result end @@ -270,7 +271,9 @@ class Array value = nil result = Primitive.ary_sized_alloc while Primitive.cexpr!(%q{ ary_fetch_next(self, LOCAL_PTR(_i), LOCAL_PTR(value)) }) - result << value if yield value + if yield value + Primitive.cexpr!(%q{ rb_ary_push(result, value) }) + end end result end |
