Skip to content

Commit

Permalink
drop string allocations in the log subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Nov 6, 2013
1 parent 267e5c8 commit 68b7e38
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions actionview/lib/action_view/log_subscriber.rb
Expand Up @@ -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?
Expand All @@ -23,8 +28,13 @@ def logger

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
Expand Down

0 comments on commit 68b7e38

Please sign in to comment.