aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/subscriber.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-02-11 11:01:13 -0500
committereileencodes <eileencodes@gmail.com>2015-02-11 11:01:13 -0500
commitfcfca5c70023ab01388a87be49a4a33e29d6cd43 (patch)
tree18273ddccf38ba70ff69988ad9b7f1f90aa0def3 /activesupport/lib/active_support/subscriber.rb
parent066d50bc83469df4fcfcab3b2c4035fdec31a6e9 (diff)
downloadrails-fcfca5c70023ab01388a87be49a4a33e29d6cd43.tar.gz
rails-fcfca5c70023ab01388a87be49a4a33e29d6cd43.tar.bz2
rails-fcfca5c70023ab01388a87be49a4a33e29d6cd43.zip
Reduce object allocations in ActiveSupport::Subscriber
Freezing the string literal reduces the number of objects allocated during integration test runs. AllocationTracer before: ``` [["/rack/lib/rack/utils.rb", 499, :T_STRING], [50939, 2737, 78553, 0, 13, 1783920]] [["/rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [44959, 0, 42633, 0, 2, 1670800]] [["/rack/lib/rack/utils.rb", 662, :T_STRING], [32979, 0, 31263, 0, 1, 1226009]] [["/rack/lib/rack/body_proxy.rb", 34, :T_ARRAY], [29988, 0, 28438, 0, 1, 1114320]] [["/rails/activesupport/lib/active_support/callbacks.rb", 165, :T_DATA], [29968, 0, 28422, 0, 2, 3675936]] ``` AllocationTracer after: ``` [["/rack/lib/rack/utils.rb", 499, :T_STRING], [50983, 4080, 67269, 0, 12, 1815600]] [["/rack/lib/rack/utils.rb", 662, :T_STRING], [33001, 0, 28420, 0, 2, 1230809]] [["/rack/lib/rack/body_proxy.rb", 34, :T_ARRAY], [29990, 0, 25812, 0, 1, 1118000]] [["/rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [29986, 0, 25803, 0, 1, 1117840]] [["/rails/activesupport/lib/active_support/notifications/instrumenter.rb", 52, :T_HASH], [29984, 28, 26133, 0, 11, 4953280]]
Diffstat (limited to 'activesupport/lib/active_support/subscriber.rb')
-rw-r--r--activesupport/lib/active_support/subscriber.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/subscriber.rb b/activesupport/lib/active_support/subscriber.rb
index 98be78b41b..cd40284660 100644
--- a/activesupport/lib/active_support/subscriber.rb
+++ b/activesupport/lib/active_support/subscriber.rb
@@ -96,7 +96,7 @@ module ActiveSupport
event.end = finished
event.payload.merge!(payload)
- method = name.split('.').first
+ method = name.split('.'.freeze).first
send(method, event)
end