Eliminate unnecessary File.exist? when correct file extension given [#1879 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
Andrew White 2009-02-05 15:38:29 -06:00 committed by Joshua Peek
parent 06182ea02e
commit 7aa847fab4
1 changed files with 2 additions and 1 deletions

View File

@ -516,7 +516,8 @@ module ActionView
def compute_public_path(source, dir, ext = nil, include_host = true)
has_request = @controller.respond_to?(:request)
if ext && (File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}")))
source_ext = File.extname(source)[1..-1]
if ext && (source_ext.blank? || (ext != source_ext && File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}"))))
source += ".#{ext}"
end