From 8f9e9118e402ea2fe1eec6fcb9a2d3f0c84b3b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 7 Oct 2010 16:25:13 +0200 Subject: Make collection rendering faster. --- actionpack/lib/abstract_controller/rendering.rb | 2 +- actionpack/lib/action_view/render/partials.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 5d9b35d297..b4ab3481d5 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -50,7 +50,7 @@ module AbstractController if controller.respond_to?(:_helpers) include controller._helpers - if controller.respond_to?(:_routes) + if controller.respond_to?(:_routes) && controller._routes include controller._routes.url_helpers include controller._routes.mounted_helpers end diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 07e844afc2..f7bdbd6917 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -307,12 +307,12 @@ module ActionView def collection_without_template segments, locals, collection_data = [], @locals, @collection_data - index, template = -1, nil + index, template, cache = -1, nil, {} keys = @locals.keys @collection.each_with_index do |object, i| path, *data = collection_data[i] - template = find_template(path, keys + data) + template = (cache[path] ||= find_template(path, keys + data)) locals[data[0]] = object locals[data[1]] = (index += 1) segments << template.render(@view, locals) -- cgit v1.2.3