From b814e792a98adb858d462e11e30e5b20e4e73d00 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 4 Dec 2017 00:44:15 -0800 Subject: [PATCH] Avoid searching for files in nonexistant dirs Search paths are determined by appending the specified dir to each directory in the load_paths. Though each dir in load_paths should exist, when a dir is specified, most load_paths dirs probably don't include it. For each dir we skip in this way (requiring one stat through File.directory?) we save 16 stat calls (2 possible prefixes, and 8 possible extensions) looking for files. --- lib/sassc/rails/importer.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/sassc/rails/importer.rb b/lib/sassc/rails/importer.rb index 63a509e..915a299 100644 --- a/lib/sassc/rails/importer.rb +++ b/lib/sassc/rails/importer.rb @@ -100,6 +100,9 @@ def imports(path, parent_path) search_paths.map! do |path| File.join(path, specified_dir) end + search_paths.select! do |path| + File.directory?(path) + end end search_paths.each do |search_path|