1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

eliminate some conditionals

This commit is contained in:
Aaron Patterson 2013-05-20 17:49:16 -07:00
parent 52ed881fa2
commit bff89a2022

View file

@ -145,10 +145,10 @@ module ActiveRecord
# Remove equalities from the existing relation with a LHS which is
# present in the relation being merged in.
def reject_overwrites(lhs_wheres, rhs_wheres)
seen = Set.new
rhs_wheres.each do |w|
seen << w.left if w.respond_to?(:operator) && w.operator == :==
nodes = rhs_wheres.find_all do |w|
w.respond_to?(:operator) && w.operator == :==
end
seen = Set.new(nodes) { |node| node.left }
lhs_wheres.reject do |w|
w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left)