Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f405ad08ed55
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 52876f8deb38
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 15, 2016

  1. Copy the full SHA
    52a4878 View commit details
  2. Copy the full SHA
    52876f8 View commit details
Showing with 3 additions and 2 deletions.
  1. +1 −0 spec/ruby/core/array/flatten_spec.rb
  2. +2 −2 truffle/src/main/ruby/core/array.rb
1 change: 1 addition & 0 deletions spec/ruby/core/array/flatten_spec.rb
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@
ArraySpecs::MyArray[].flatten.should be_an_instance_of(ArraySpecs::MyArray)
ArraySpecs::MyArray[1, 2, 3].flatten.should be_an_instance_of(ArraySpecs::MyArray)
ArraySpecs::MyArray[1, [2], 3].flatten.should be_an_instance_of(ArraySpecs::MyArray)
ArraySpecs::MyArray[1, [2, 3], 4].flatten.should == ArraySpecs::MyArray[1, 2, 3, 4]
[ArraySpecs::MyArray[1, 2, 3]].flatten.should be_an_instance_of(Array)
end

4 changes: 2 additions & 2 deletions truffle/src/main/ruby/core/array.rb
Original file line number Diff line number Diff line change
@@ -412,7 +412,7 @@ def flatten(level=-1)
level = Rubinius::Type.coerce_to_collection_index level
return self.dup if level == 0

out = [] # new_reserved size
out = self.class.allocate # new_reserved size
recursively_flatten(self, out, level)
Rubinius::Type.infect(out, self)
out
@@ -424,7 +424,7 @@ def flatten!(level=-1)
level = Rubinius::Type.coerce_to_collection_index level
return nil if level == 0

out = [] # new_reserved size
out = self.class.allocate # new_reserved size
if recursively_flatten(self, out, level)
Truffle::Array.steal_storage(self, out)
return self