提交 b925074b 编写于 作者: G Guo Xiang Tan

Reduce number of subscriptions created.

上级 e0c6b35d
......@@ -30,25 +30,21 @@ def setup_subscriptions
end
@_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
path = payload[:virtual_path]
next unless path
partial = path =~ /^.*\/_[^\/]*$/
if virtual_path = payload[:virtual_path]
partial = virtual_path =~ /^.*\/_[^\/]*$/
if partial
@_partials[path] += 1
@_partials[path.split("/").last] += 1
end
@_templates[path] += 1
end
@_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
next if payload[:virtual_path] # files don't have virtual path
if partial
@_partials[virtual_path] += 1
@_partials[virtual_path.split("/").last] += 1
end
path = payload[:identifier]
if path
@_files[path] += 1
@_files[path.split("/").last] += 1
@_templates[virtual_path] += 1
else
path = payload[:identifier]
if path
@_files[path] += 1
@_files[path.split("/").last] += 1
end
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册