1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Avoid building full path objects when cached

This commit is contained in:
John Hawthorn 2021-07-13 14:51:23 -07:00
parent 4db7ae52f8
commit bb5208692a

View file

@ -122,16 +122,12 @@ module ActionView
private private
def _find_all(name, prefix, partial, details, key, locals) def _find_all(name, prefix, partial, details, key, locals)
path = TemplatePath.build(name, prefix, partial)
requested_details = key || TemplateDetails::Requested.new(**details) requested_details = key || TemplateDetails::Requested.new(**details)
query(path, requested_details, locals, cache: !!key) cache = key ? @unbound_templates : Concurrent::Map.new
end
def query(path, requested_details, locals, cache:)
cache = cache ? @unbound_templates : Concurrent::Map.new
unbound_templates = unbound_templates =
cache.compute_if_absent(path.virtual) do cache.compute_if_absent(TemplatePath.virtual(name, prefix, partial)) do
path = TemplatePath.build(name, prefix, partial)
unbound_templates_from_path(path) unbound_templates_from_path(path)
end end