1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Save a hash allocation in MySQL statement pool

There's no need to wrap the statement in a hash with a single key.
This commit is contained in:
Eugene Kenny 2018-04-23 22:00:40 +01:00
parent e970d15211
commit f2a9063373
2 changed files with 2 additions and 5 deletions

View file

@ -44,7 +44,7 @@ module ActiveRecord
class StatementPool < ConnectionAdapters::StatementPool # :nodoc:
private def dealloc(stmt)
stmt[:stmt].close
stmt.close
end
end

View file

@ -71,10 +71,7 @@ module ActiveRecord
log(sql, name, binds, type_casted_binds) do
if cache_stmt
cache = @statements[sql] ||= {
stmt: @connection.prepare(sql)
}
stmt = cache[:stmt]
stmt = @statements[sql] ||= @connection.prepare(sql)
else
stmt = @connection.prepare(sql)
end