diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-30 08:23:42 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-30 08:23:42 +0000 |
commit | 5640f76970c9b68f74df9da5cfa9763833e00d78 (patch) | |
tree | b534cf4d2e56cd67d36e58503d03cb2ffcacec21 | |
parent | be27caf92db41f1a5dc94e7c2913467e7e493eeb (diff) | |
download | rails-5640f76970c9b68f74df9da5cfa9763833e00d78.tar.gz rails-5640f76970c9b68f74df9da5cfa9763833e00d78.tar.bz2 rails-5640f76970c9b68f74df9da5cfa9763833e00d78.zip |
Improved the speed of regular expression expirations for caching by a factor of 10 #1221 [Jamis Buck]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 23 |
2 files changed, 12 insertions, 13 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 1c2e54418f..e1c1ef5391 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Improved the speed of regular expression expirations for caching by a factor of 10 #1221 [Jamis Buck] + * Removed dumping of template assigns on the rescue page as it would very easily include a ton of data making page loads take seconds (and the information was rarely helpful) #1222 * Added BenchmarkHelper that can measure the execution time of a block in a template and reports the result to the log. Example: diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index 0254c2d98d..92eb8770df 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -368,8 +368,8 @@ module ActionController #:nodoc: end def delete_matched(matcher, options) #:nodoc: - search_dir(@cache_path).each do |f| - File.delete(f) if f =~ matcher && File.exist?(f) + search_dir(@cache_path) do |f| + File.delete(f) rescue nil if f =~ matcher end end @@ -382,19 +382,16 @@ module ActionController #:nodoc: FileUtils.makedirs(path) unless File.exists?(path) end - def search_dir(dir) - require 'pathname' - files = [] - dir = Dir.new(dir) - dir.each do |d| - unless d == '.' or d == '..' - d = File.join(dir.path, d) - p = Pathname.new(d) - files << p.to_s if p.file? - files += search_dir(d) if p.directory? + def search_dir(dir, &callback) + Dir.foreach(dir) do |d| + next if d == "." || d == ".." + name = File.join(dir, d) + if File.directory?(name) + search_dir(name, &callback) + else + callback.call name end end - files end end end |