From 5b10173364a56458e3f2e8a44298722cda9321e7 Mon Sep 17 00:00:00 2001 From: Adrien Thebo Date: Tue, 5 Apr 2011 12:18:11 -0700 Subject: (#5135) Fix faulty logic in physicalprocessorcount - Was doing unnessary string manipulation when all that needed to be done was a uniq'd array. - Removed some backwards way of nil checking. --- lib/facter/physicalprocessorcount.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/facter/physicalprocessorcount.rb b/lib/facter/physicalprocessorcount.rb index c6145dc..22c00c1 100644 --- a/lib/facter/physicalprocessorcount.rb +++ b/lib/facter/physicalprocessorcount.rb @@ -39,10 +39,7 @@ Facter.add('physicalprocessorcount') do lookup_pattern = "#{sysfs_cpu_directory}" + "/cpu*/topology/physical_package_id" - ids = Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")} - - ids = ids.join if ids.is_a?(Array) - ids.scan(/\d+/).uniq.size + Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")}.uniq.size else # @@ -53,7 +50,7 @@ Facter.add('physicalprocessorcount') do # str = Facter::Util::Resolution.exec("grep 'physical.\\+:' /proc/cpuinfo") - if not str.nil? then str.scan(/\d+/).uniq.size; end + if str then str.scan(/\d+/).uniq.size; end end end end -- cgit