diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-11-06 14:37:30 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-11-06 14:37:30 -0800 |
commit | 68b7e381f1c9a0ee9689ea56f14ae2a3ac8fd182 (patch) | |
tree | c330bb81daa8e7898b4c8af27057a812dc2dcc17 /actionview | |
parent | 267e5c84f96b96f8eac9f4a3dcdce5bc1b82541c (diff) | |
download | rails-68b7e381f1c9a0ee9689ea56f14ae2a3ac8fd182.tar.gz rails-68b7e381f1c9a0ee9689ea56f14ae2a3ac8fd182.tar.bz2 rails-68b7e381f1c9a0ee9689ea56f14ae2a3ac8fd182.zip |
drop string allocations in the log subscriber
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/log_subscriber.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/actionview/lib/action_view/log_subscriber.rb b/actionview/lib/action_view/log_subscriber.rb index 354a136894..9336b29d0b 100644 --- a/actionview/lib/action_view/log_subscriber.rb +++ b/actionview/lib/action_view/log_subscriber.rb @@ -5,7 +5,12 @@ module ActionView # # Provides functionality so that Rails can output logs from Action View. class LogSubscriber < ActiveSupport::LogSubscriber - VIEWS_PATTERN = /^app\/views\//.freeze + VIEWS_PATTERN = /^app\/views\// + + def initialize + @root = nil + super + end def render_template(event) return unless logger.info? @@ -23,8 +28,13 @@ module ActionView protected + EMPTY = '' def from_rails_root(string) - string.sub("#{Rails.root}/", "").sub(VIEWS_PATTERN, "") + string.sub(rails_root, EMPTY).sub(VIEWS_PATTERN, EMPTY) + end + + def rails_root + @root ||= "#{Rails.root}/" end end end |