Skip to content

Commit

Permalink
eliminate some conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 21, 2013
1 parent 52ed881 commit bff89a2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions activerecord/lib/active_record/relation/merger.rb
Expand Up @@ -145,10 +145,10 @@ def merged_wheres
# Remove equalities from the existing relation with a LHS which is # Remove equalities from the existing relation with a LHS which is
# present in the relation being merged in. # present in the relation being merged in.
def reject_overwrites(lhs_wheres, rhs_wheres) def reject_overwrites(lhs_wheres, rhs_wheres)
seen = Set.new nodes = rhs_wheres.find_all do |w|
rhs_wheres.each do |w| w.respond_to?(:operator) && w.operator == :==
seen << w.left if w.respond_to?(:operator) && w.operator == :==
end end
seen = Set.new(nodes) { |node| node.left }


lhs_wheres.reject do |w| lhs_wheres.reject do |w|
w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left) w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left)
Expand Down

0 comments on commit bff89a2

Please sign in to comment.