mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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:
parent
aa3acf85cb
commit
3dd7cecfe3
1 changed files with 8 additions and 4 deletions
|
@ -148,11 +148,15 @@ module ActiveRecord
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue