Permalink
Browse files

eliminate some conditionals

  • Loading branch information...
1 parent 52ed881 commit bff89a2022aedec60929f6d6744eefc84a5c102a @tenderlove tenderlove committed May 21, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/relation/merger.rb
@@ -145,10 +145,10 @@ def merged_wheres
# 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)

0 comments on commit bff89a2

Please sign in to comment.