Skip to content

Commit

Permalink
Avoid a hash object allocation per each query/execute call (#1112)
Browse files Browse the repository at this point in the history
This is a same optimization approach with ruby/ruby#2393.
  • Loading branch information
kamipo authored Mar 10, 2020
1 parent cb9e941 commit c66eb36
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/mysql2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ def self.key_hash_as_symbols(hash)
else
::Timeout::Error
end
TIMEOUT_ERROR_NEVER = { TIMEOUT_ERROR_CLASS => :never }.freeze
end
end
2 changes: 1 addition & 1 deletion lib/mysql2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def parse_connect_attrs(conn_attrs)
end

def query(sql, options = {})
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_NEVER) do
_query(sql, @query_options.merge(options))
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mysql2/statement.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Mysql2
class Statement
def execute(*args, **kwargs)
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_NEVER) do
_execute(*args, **kwargs)
end
end
Expand Down

0 comments on commit c66eb36

Please sign in to comment.