Skip to content

Commit

Permalink
Showing 3 changed files with 28 additions and 350 deletions.
Original file line number Diff line number Diff line change
@@ -1722,7 +1722,6 @@ public Object getTruffleKernelModule() {
"/core/hash.rb",
"/core/array.rb",
"/core/kernel.rb",
"/core/identity_map.rb",
"/core/comparable.rb",
"/core/numeric_mirror.rb",
"/core/numeric.rb",
46 changes: 28 additions & 18 deletions truffle/src/main/ruby/core/array.rb
Original file line number Diff line number Diff line change
@@ -58,30 +58,26 @@ def self.try_convert(obj)
def &(other)
other = Rubinius::Type.coerce_to other, Array, :to_ary

array = []
im = Rubinius::IdentityMap.from other

each { |x| array << x if im.delete x }

array
h = {}
other.each { |e| h[e] = true }
select { |x| h.delete x }
end

def |(other)
other = Rubinius::Type.coerce_to other, Array, :to_ary

im = Rubinius::IdentityMap.from self, other
im.to_array
h = {}
each { |e| h[e] = true }
other.each { |e| h[e] = true }
h.keys
end

def -(other)
other = Rubinius::Type.coerce_to other, Array, :to_ary

array = []
im = Rubinius::IdentityMap.from other

each { |x| array << x unless im.include? x }

array
h = {}
other.each { |e| h[e] = true }
reject { |x| h.include? x }
end

def <=>(other)
@@ -1518,14 +1514,28 @@ def delete_range(index, del_length)
def uniq!(&block)
Truffle.check_frozen

result = []
if block_given?
im = Rubinius::IdentityMap.from(self, &block)
h = {}
each { |e|
v = yield(e)
unless h.key?(v)
h[v] = true
result << e
end
}
else
im = Rubinius::IdentityMap.from(self)
h = {}
each { |e|
unless h.key?(e)
h[e] = true
result << e
end
}
end
return if im.size == size
return if result.size == size

Truffle::Array.steal_storage(self, im.to_array)
Truffle::Array.steal_storage(self, result)
self
end

331 changes: 0 additions & 331 deletions truffle/src/main/ruby/core/identity_map.rb

This file was deleted.

0 comments on commit 7007ea0

Please sign in to comment.