From 688c10c31d0485d7edafbc688f8acfeb36e3dd2b Mon Sep 17 00:00:00 2001 From: dcrosby Date: Tue, 23 Apr 2024 10:50:05 -0700 Subject: [PATCH] [CookbookVersionLoader#load_all_files] Do directory test after name check Simple string comparison is cheaper than a `stat` Signed-off-by: David Crosby --- lib/chef/cookbook/cookbook_version_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index 00cf22e6da5..a357c271b9b 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -215,7 +215,7 @@ def load_all_files Dir.entries(cookbook_path).each do |top_filename| # Skip top-level directories starting with "." top_path = File.join(cookbook_path, top_filename) - next if File.directory?(top_path) && top_filename.start_with?(".") + next if top_filename.start_with?(".") && File.directory?(top_path) # Use Find.find because it: # (a) returns any children, recursively