Permalink
Browse files

array subtraction should be faster than iterating over all the elements

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
Neeraj Singh authored and josevalim committed Jun 29, 2010
1 parent e8f88a3 commit dabf74b4950f486075b380f2406ede9fa67606db
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/relation/spawn_methods.rb
@@ -6,7 +6,7 @@ def merge(r)
merged_relation = clone
return merged_relation unless r
- (Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS).reject {|m| [:joins, :where].include?(m)}.each do |method|
+ ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) - [:joins, :where]).each do |method|
value = r.send(:"#{method}_values")
merged_relation.send(:"#{method}_values=", value) if value.present?
end

0 comments on commit dabf74b

Please sign in to comment.