提交 3dd7cecf 编写于 作者: S Sean Griffin

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.
上级 aa3acf85
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册