提交 dde7134e 编写于 作者: S Stan Lo

Freeze fragment cache related instrument name.

ActionMailer::Base#instrument_name and
ActionController::Base#instrument_name will be frequently called once
caching is enabled. So it's better to freeze them instead of create new
string on every call.

Also, the instrument name in #instrument_fragment_cache will usually
be "write_fragment.action_controller" or
"read_fragment.action_controller". So freezing them might also gain some
performance improvement. We have done something like this in other places:
https://github.com/rails/rails/blob/master/actionview/lib/action_view/template.rb#L348
上级 e3afc836
......@@ -972,7 +972,7 @@ def instrument_payload(key)
end
def instrument_name
"action_mailer"
"action_mailer".freeze
end
ActiveSupport.run_load_hooks(:action_mailer, self)
......
......@@ -136,7 +136,7 @@ def expire_fragment(key, options = nil)
def instrument_fragment_cache(name, key) # :nodoc:
payload = instrument_payload(key)
ActiveSupport::Notifications.instrument("#{name}.#{instrument_name}", payload) { yield }
ActiveSupport::Notifications.instrument("#{name}.#{instrument_name}".freeze, payload) { yield }
end
end
end
......
......@@ -38,7 +38,7 @@ def instrument_payload(key)
end
def instrument_name
"action_controller"
"action_controller".freeze
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册