aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2015-02-26 23:22:22 -0500
committerJack Nagel2015-02-27 20:38:01 -0500
commit1255f7b89492327fab822ad8254f0781acede888 (patch)
tree0333bde9b36ccc307a870a329e5f563948b1a3d6 /Library
parent37c394f828217420ed3d96420aea55b21382fd95 (diff)
downloadbrew-1255f7b89492327fab822ad8254f0781acede888.tar.bz2
Move caching from sysctl_bool to sysctl_n
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/os/mac/hardware.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb
index 40ab70e13..9937251df 100644
--- a/Library/Homebrew/os/mac/hardware.rb
+++ b/Library/Homebrew/os/mac/hardware.rb
@@ -15,8 +15,7 @@ module MacCPUs
# These methods use info spewed out by sysctl.
# Look in <mach/machine.h> for decoding info.
def type
- @type ||= sysctl_int("hw.cputype")
- case @type
+ case sysctl_int("hw.cputype")
when 7
:intel
when 18
@@ -28,7 +27,7 @@ module MacCPUs
def family
if intel?
- case @intel_family ||= sysctl_int("hw.cpufamily")
+ case sysctl_int("hw.cpufamily")
when 0x73d67300 # Yonah: Core Solo/Duo
:core
when 0x426f69ef # Merom: Core 2 Duo
@@ -49,7 +48,7 @@ module MacCPUs
:dunno
end
elsif ppc?
- case @ppc_family ||= sysctl_int("hw.cpusubtype")
+ case sysctl_int("hw.cpusubtype")
when 9
:g3 # PowerPC 750
when 10
@@ -67,15 +66,15 @@ module MacCPUs
end
def extmodel
- @extmodel ||= sysctl_int("machdep.cpu.extmodel")
+ sysctl_int("machdep.cpu.extmodel")
end
def cores
- @cores ||= sysctl_int("hw.ncpu")
+ sysctl_int("hw.ncpu")
end
def bits
- @bits ||= sysctl_bool("hw.cpu64bit_capable") ? 64 : 32
+ sysctl_bool("hw.cpu64bit_capable") ? 64 : 32
end
def arch_32_bit
@@ -138,10 +137,8 @@ module MacCPUs
protected
- def sysctl_bool(property)
- (@properties ||= {}).fetch(property) do
- @properties[property] = sysctl_int(property) == 1 && $?.success?
- end
+ def sysctl_bool(key)
+ sysctl_int(key) == 1 && $?.success?
end
def sysctl_int(key)
@@ -149,6 +146,8 @@ module MacCPUs
end
def sysctl_n(key)
- Utils.popen_read("/usr/sbin/sysctl", "-n", key)
+ (@properties ||= {}).fetch(key) do
+ @properties[key] = Utils.popen_read("/usr/sbin/sysctl", "-n", key)
+ end
end
end