提交 3c356aa9 编写于 作者: J Jeremy Kemper

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
上级 2c7715a0
*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
......
......@@ -522,9 +522,10 @@ def compile_template?(template, file_name, local_assigns)
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 @@ def compile_template?(template, file_name, local_assigns)
# 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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册