aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/render/partials.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-08 23:43:45 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-09 04:12:08 -0300
commit0ab40b039bf7b7882a31ab187916bc2dc5a8ae7c (patch)
tree873f2acc966ef3e3f68b3c0f7f0375c43c49813b /actionpack/lib/action_view/render/partials.rb
parent930d235981c429bde8a604622393f70ec69a4985 (diff)
downloadrails-0ab40b039bf7b7882a31ab187916bc2dc5a8ae7c.tar.gz
rails-0ab40b039bf7b7882a31ab187916bc2dc5a8ae7c.tar.bz2
rails-0ab40b039bf7b7882a31ab187916bc2dc5a8ae7c.zip
Went from 25% slower partials (vs. 2.3) to 10% faster. More to come.
Diffstat (limited to 'actionpack/lib/action_view/render/partials.rb')
-rw-r--r--actionpack/lib/action_view/render/partials.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb
index e7d03c81e8..7a8c943b05 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/render/partials.rb
@@ -177,6 +177,10 @@ module ActionView
@partial_names ||= Hash.new {|h,k| h[k] = ActiveSupport::ConcurrentHash.new }
end
+ def self.formats
+ @formats ||= Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = {}}}
+ end
+
def initialize(view_context, options, block)
partial = options[:partial]
@@ -187,8 +191,8 @@ module ActionView
# Set up some instance variables to speed up memoizing
@partial_names = self.class.partial_names[@view.controller.class]
- @templates = Hash.new {|h,k| h[k] = {}}
- @formats_hash = view_context.formats.hash
+ @templates = self.class.formats
+ @details_hash = [view_context.formats, I18n.locale].hash
# Set up the object and path
@object = partial.is_a?(String) ? options[:object] : partial
@@ -248,7 +252,7 @@ module ActionView
def find_template(path = @path)
return if !path
- @templates[path][@formats_hash] ||= begin
+ @templates[@details_hash][path][@view.controller_path] ||= begin
prefix = @view.controller.controller_path unless path.include?(?/)
@view.find(path, {:formats => @view.formats}, prefix, true)
end