Skip to content

Commit

Permalink
Save a hash allocation in MySQL statement pool
Browse files Browse the repository at this point in the history
There's no need to wrap the statement in a hash with a single key.
  • Loading branch information
eugeneius committed Apr 23, 2018
1 parent e970d15 commit f2a9063
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Expand Up @@ -44,7 +44,7 @@ class AbstractMysqlAdapter < AbstractAdapter

class StatementPool < ConnectionAdapters::StatementPool # :nodoc:
private def dealloc(stmt)
stmt[:stmt].close
stmt.close
end
end

Expand Down
Expand Up @@ -71,10 +71,7 @@ def exec_stmt_and_free(sql, name, binds, cache_stmt: false)

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
Expand Down

0 comments on commit f2a9063

Please sign in to comment.