aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorStan Lo <a22301613@yahoo.com.tw>2017-02-07 00:31:44 +0800
committerStan Lo <a22301613@yahoo.com.tw>2017-02-07 00:41:02 +0800
commitdde7134e07cb84f2efcf9704de144ef9ed38d360 (patch)
treeffebf9e8e045960c11b6a14d1a3cd8a433fe1e22 /actionpack
parente3afc83631ebe2dbb3c4368756577bdd92ea1d62 (diff)
downloadrails-dde7134e07cb84f2efcf9704de144ef9ed38d360.tar.gz
rails-dde7134e07cb84f2efcf9704de144ef9ed38d360.tar.bz2
rails-dde7134e07cb84f2efcf9704de144ef9ed38d360.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/abstract_controller/caching/fragments.rb2
-rw-r--r--actionpack/lib/action_controller/caching.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/abstract_controller/caching/fragments.rb b/actionpack/lib/abstract_controller/caching/fragments.rb
index c85b4adba1..13fa2b393d 100644
--- a/actionpack/lib/abstract_controller/caching/fragments.rb
+++ b/actionpack/lib/abstract_controller/caching/fragments.rb
@@ -136,7 +136,7 @@ module AbstractController
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
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index a9a8508abc..954265ad97 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -38,7 +38,7 @@ module ActionController
end
def instrument_name
- "action_controller"
+ "action_controller".freeze
end
end
end