diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-27 19:16:09 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-27 19:16:09 +0000 |
commit | 3c356aa9ffca7d087a7d8a88f08df1e518816475 (patch) | |
tree | 72aa9fb5297d0377432287493fd7af43fd7e2b85 /actionpack | |
parent | 2c7715a0cfe4524bf57be771bfb66bb0522bf6f8 (diff) | |
download | rails-3c356aa9ffca7d087a7d8a88f08df1e518816475.tar.gz rails-3c356aa9ffca7d087a7d8a88f08df1e518816475.tar.bz2 rails-3c356aa9ffca7d087a7d8a88f08df1e518816475.zip |
Reduce file stat calls when checking for template changes. Closes #7736.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6871 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 3151f05077..ef28e1b7bb 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Reduce file stat calls when checking for template changes. #7736 [alex] + * Added custom path cache_page/expire_page parameters in addition to the options hashes [DHH]. Example: def index diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index f6885fa292..61d4bd7ad2 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -522,9 +522,10 @@ module ActionView #:nodoc: method_key = file_name || template render_symbol = @@method_names[method_key] - if @@compile_time[render_symbol] && supports_local_assigns?(render_symbol, local_assigns) + compile_time = @@compile_time[render_symbol] + if compile_time && supports_local_assigns?(render_symbol, local_assigns) if file_name && !@@cache_template_loading - template_changed_since?(file_name, @@compile_time[render_symbol]) + template_changed_since?(file_name, compile_time) end else true @@ -534,8 +535,9 @@ module ActionView #:nodoc: # Method to handle checking a whether a template has changed since last compile; isolated so that templates # not stored on the file system can hook and extend appropriately. def template_changed_since?(file_name, compile_time) - compile_time < File.mtime(file_name) || - (File.symlink?(file_name) && (compile_time < File.lstat(file_name).mtime)) + lstat = File.lstat(file_name) + compile_time < lstat.mtime || + (lstat.symlink? && compile_time < File.stat(file_name).mtime) end # Method to create the source code for a given template. |