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

Cache connection access.

This commit is contained in:
José Valim 2010-07-25 21:01:49 +02:00
parent 304c49b146
commit 331df84cc9
2 changed files with 4 additions and 6 deletions

View file

@ -6,6 +6,7 @@ module ActiveRecord
end
def sql(event)
connection = ActiveRecord::Base.connection
connection.runtime += event.duration
return unless logger.debug?
@ -26,10 +27,6 @@ module ActiveRecord
@odd_or_even = !@odd_or_even
end
def connection
ActiveRecord::Base.connection
end
def logger
ActiveRecord::Base.logger
end

View file

@ -11,9 +11,10 @@ module ActiveRecord
def cleanup_view_runtime
if ActiveRecord::Base.connected?
db_rt_before_render = ActiveRecord::Base.connection.reset_runtime
connection = ActiveRecord::Base.connection
db_rt_before_render = connection.reset_runtime
runtime = super
db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
db_rt_after_render = connection.reset_runtime
self.db_runtime = db_rt_before_render + db_rt_after_render
runtime - db_rt_after_render
else