diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-08-03 16:26:57 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-08-03 16:26:57 -0700 |
commit | 4760619710e7446a6e2b3dad34cdb7369b97aff7 (patch) | |
tree | 5c3b16d7e5c6bc282aed6809c6ae6e006126b30a | |
parent | c202ce4e318a6bc842158970aeb6b3d13fa6a0df (diff) | |
download | chef-4760619710e7446a6e2b3dad34cdb7369b97aff7.tar.gz |
Use .count instead of .select{}.count
Avoid creating an array only to count it.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/run_context/cookbook_compiler.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb index 9d8ea87360..e1e4c215ad 100644 --- a/lib/chef/run_context/cookbook_compiler.rb +++ b/lib/chef/run_context/cookbook_compiler.rb @@ -325,7 +325,7 @@ class Chef def count_files_by_segment(segment, root_alias = nil) cookbook_collection.inject(0) do |count, cookbook_by_name| - count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).select { |record| record[:name] == root_alias }.size : 0) + count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).count { |record| record[:name] == root_alias } : 0) end end |