aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2015-07-25 00:08:47 -0500
committerschneems <richard.schneeman@gmail.com>2015-07-29 20:41:58 -0500
commit9b189a31696b6572ffb8164f1f3041d57e8eeebe (patch)
treef121e8723a58ad88092b0ea499f457a8495ce7d1 /actionview
parent2e95d2ef90a32a7ed6fbb14f4e0a6764fc9e017b (diff)
downloadrails-9b189a31696b6572ffb8164f1f3041d57e8eeebe.tar.gz
rails-9b189a31696b6572ffb8164f1f3041d57e8eeebe.tar.bz2
rails-9b189a31696b6572ffb8164f1f3041d57e8eeebe.zip
Cut string ActionView template allocations
The instrument method creates new strings, the most common action to instrument is "!render_template` so we can detect when that action is occurring and use a frozen string instead. This change buys us 113,714 bytes of memory and 1,790 fewer objects per request.
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/template.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index 1ce9f94b13..e232808dcb 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -154,7 +154,7 @@ module ActionView
# we use a bang in this instrumentation because you don't want to
# consume this in production. This is only slow if it's being listened to.
def render(view, locals, buffer=nil, &block)
- instrument("!render_template") do
+ instrument("!render_template".freeze) do
compile!(view)
view.send(method_name, locals, buffer, &block)
end
@@ -348,7 +348,12 @@ module ActionView
def instrument(action, &block)
payload = { virtual_path: @virtual_path, identifier: @identifier }
- ActiveSupport::Notifications.instrument("#{action}.action_view", payload, &block)
+ case action
+ when "!render_template".freeze
+ ActiveSupport::Notifications.instrument("!render_template.action_view".freeze, payload, &block)
+ else
+ ActiveSupport::Notifications.instrument("#{action}.action_view".freeze, payload, &block)
+ end
end
EXPLICIT_COLLECTION = /# Template Collection: (?<resource_name>\w+)/