(#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.
Adrien Thebo authored 13 years ago
James Turnbull committed 13 years ago
38 | 38 | lookup_pattern = "#{sysfs_cpu_directory}" + |
39 | 39 | "/cpu*/topology/physical_package_id" |
40 | 40 | |
41 | ids = Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")} | |
42 | ||
43 | ids = ids.join if ids.is_a?(Array) | |
44 | ids.scan(/\d+/).uniq.size | |
41 | Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")}.uniq.size | |
45 | 42 | |
46 | 43 | else |
47 | 44 | # |
52 | 49 | # |
53 | 50 | str = Facter::Util::Resolution.exec("grep 'physical.\\+:' /proc/cpuinfo") |
54 | 51 | |
55 | if not str.nil? then str.scan(/\d+/).uniq.size; end | |
52 | if str then str.scan(/\d+/).uniq.size; end | |
56 | 53 | end |
57 | 54 | end |
58 | 55 | end |