aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/resolver.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-09 09:46:50 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-11 15:03:52 -0700
commit02d9dd900048407ef555cf09b0038a57ae924b0a (patch)
treec94879aa6c0dcdd82226114e31cefdb7abac7678 /actionpack/lib/action_view/template/resolver.rb
parent04d4537cd40d0415d15af4395213632735c8683f (diff)
downloadrails-02d9dd900048407ef555cf09b0038a57ae924b0a.tar.gz
rails-02d9dd900048407ef555cf09b0038a57ae924b0a.tar.bz2
rails-02d9dd900048407ef555cf09b0038a57ae924b0a.zip
Add some more caching to the lookup
Diffstat (limited to 'actionpack/lib/action_view/template/resolver.rb')
-rw-r--r--actionpack/lib/action_view/template/resolver.rb30
1 files changed, 18 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index 3bd2acae7a..10f664736f 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -62,6 +62,10 @@ module ActionView
class FileSystemResolver < Resolver
+ def self.cached_glob
+ @@cached_glob ||= {}
+ end
+
def initialize(path, options = {})
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
super(options)
@@ -107,20 +111,22 @@ module ActionView
# :api: plugin
def details_to_glob(name, details, prefix, partial, root)
- path = ""
- path << "#{prefix}/" unless prefix.empty?
- path << (partial ? "_#{name}" : name)
-
- extensions = ""
- [:locales, :formats].each do |k|
- extensions << if exts = details[k]
- '{' + exts.map {|e| ".#{e},"}.join + '}'
- else
- k == :formats ? formats_glob : ''
+ self.class.cached_glob[[name, prefix, partial, details, root]] ||= begin
+ path = ""
+ path << "#{prefix}/" unless prefix.empty?
+ path << (partial ? "_#{name}" : name)
+
+ extensions = ""
+ [:locales, :formats].each do |k|
+ extensions << if exts = details[k]
+ '{' + exts.map {|e| ".#{e},"}.join + '}'
+ else
+ k == :formats ? formats_glob : ''
+ end
end
- end
- "#{root}#{path}#{extensions}#{handler_glob}"
+ "#{root}#{path}#{extensions}#{handler_glob}"
+ end
end
# TODO: fix me