aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/hardware.rb
diff options
context:
space:
mode:
authorJack Nagel2012-04-11 20:19:52 -0500
committerJack Nagel2012-07-02 01:10:21 -0500
commit4043be7c7f32c750f922224c84ccf197f9268693 (patch)
treebadd8ffa4b28617b73657c1f2a5d9eee2830bdf9 /Library/Homebrew/hardware.rb
parentd4bf6a3d823473b35ef20a495664e53e6343bfaf (diff)
downloadhomebrew-4043be7c7f32c750f922224c84ccf197f9268693.tar.bz2
Cache Hardware.is_64_bit?
IO#popen is called for each call to Hardware.is_64_bit?; this becomes costly when it is repeatedly invoked. Luckily it is an invariant, so we can store it in a class variable. False is a valid value for this method, so the usual ||= idiom is not applicable. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/hardware.rb')
-rw-r--r--Library/Homebrew/hardware.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb
index 8716cd270..426ab4c49 100644
--- a/Library/Homebrew/hardware.rb
+++ b/Library/Homebrew/hardware.rb
@@ -55,7 +55,8 @@ class Hardware
end
def self.is_64_bit?
- self.sysctl_bool("hw.cpu64bit_capable")
+ return @@is_64_bit if defined? @@is_64_bit
+ @@is_64_bit = self.sysctl_bool("hw.cpu64bit_capable")
end
def self.bits