Don't allocate a bunch of strings in Relation::Merger

Since the strings are dynamically computed from a constant, the actual
strings we're creating are a known set. We can compute them ahead of
time, and reduce the number of allocations in that method.
This commit is contained in:
Sean Griffin 2015-09-02 10:39:29 -06:00
parent aa3acf85cb
commit 3dd7cecfe3

@ -148,11 +148,15 @@ def merge_single_values
end
end
CLAUSE_METHOD_NAMES = CLAUSE_METHODS.map do |name|
["#{name}_clause", "#{name}_clause="]
end
def merge_clauses
CLAUSE_METHODS.each do |name|
clause = relation.send("#{name}_clause")
other_clause = other.send("#{name}_clause")
relation.send("#{name}_clause=", clause.merge(other_clause))
CLAUSE_METHOD_NAMES.each do |(reader, writer)|
clause = relation.send(reader)
other_clause = other.send(reader)
relation.send(writer, clause.merge(other_clause))
end
end
end