diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2024-07-29 13:28:57 -0700 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2024-07-29 14:18:11 -0700 |
| commit | 2c1655314a0700a90b7ed12bf8c920ad2d78654f (patch) | |
| tree | ec758c9e97cc71adf644b85a622c279766ad8646 /array.rb | |
| parent | acbb8d4fb56ac3b5894991760a075dbef78d10e3 (diff) | |
Revert moving things to Ruby
This is slowing down benchmarks on x86, so lets revert it for now.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11275
Diffstat (limited to 'array.rb')
| -rw-r--r-- | array.rb | 67 |
1 files changed, 0 insertions, 67 deletions
@@ -56,73 +56,6 @@ class Array end # call-seq: - # array.map {|element| ... } -> new_array - # array.map -> new_enumerator - # - # Calls the block, if given, with each element of +self+; - # returns a new +Array+ whose elements are the return values from the block: - # - # a = [:foo, 'bar', 2] - # a1 = a.map {|element| element.class } - # a1 # => [Symbol, String, Integer] - # - # Returns a new Enumerator if no block given: - # a = [:foo, 'bar', 2] - # a1 = a.map - # a1 # => #<Enumerator: [:foo, "bar", 2]:map> - def map - Primitive.attr! :inline_block - - unless defined?(yield) - return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)' - end - - _i = 0 - value = nil - result = Primitive.ary_sized_alloc - while Primitive.cexpr!(%q{ ary_fetch_next(self, LOCAL_PTR(_i), LOCAL_PTR(value)) }) - result << yield(value) - end - result - end - - alias collect map - - # call-seq: - # array.select {|element| ... } -> new_array - # array.select -> new_enumerator - # - # Calls the block, if given, with each element of +self+; - # returns a new +Array+ containing those elements of +self+ - # for which the block returns a truthy value: - # - # a = [:foo, 'bar', 2, :bam] - # a1 = a.select {|element| element.to_s.start_with?('b') } - # a1 # => ["bar", :bam] - # - # Returns a new Enumerator if no block given: - # - # a = [:foo, 'bar', 2, :bam] - # a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select> - def select - Primitive.attr! :inline_block - - unless defined?(yield) - return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)' - end - - _i = 0 - 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 - end - result - end - - alias filter select - - # call-seq: # array.shuffle!(random: Random) -> array # # Shuffles the elements of +self+ in place. |
