diff options
Diffstat (limited to 'array.rb')
| -rw-r--r-- | array.rb | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -71,7 +71,7 @@ class Array # # The order of the result array is unrelated to the order of +self+. # - # Returns a new empty +Array+ if +self+ is empty: + # Returns a new empty array if +self+ is empty: # # [].sample(4) # => [] # @@ -212,7 +212,7 @@ class Array indexes end - with_yjit do + with_jit do if Primitive.rb_builtin_basic_definition_p(:each) undef :each @@ -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 |
