From 43d0c8a2a1558c1f0f922765eed711653be7e5e2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 18 Jan 2013 09:14:14 -0800 Subject: [PATCH] Perform extension test once This does not need to be computed on each path since file isn't changing between paths visited --- src/stdlib/require.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stdlib/require.coffee b/src/stdlib/require.coffee index 14b1a0506..1076bcc49 100644 --- a/src/stdlib/require.coffee +++ b/src/stdlib/require.coffee @@ -82,9 +82,10 @@ resolve = (name, {verifyExistence}={}) -> file = expanded if not moduleAlreadyLoaded + hasExtension = /\.(.+)$/.test(file) paths.some (path) -> - fileExists = /\.(.+)$/.test(file) and __exists "#{path}/#{file}" - jsFileExists = not /\.(.+)$/.test(file) and __exists "#{path}/#{file}.js" + fileExists = hasExtension and __exists "#{path}/#{file}" + jsFileExists = not hasExtension and __exists "#{path}/#{file}.js" if jsFileExists file = "#{path}/#{file}.js"