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>
This commit is contained in:
parent
168ccb2821
commit
ca71c038a1
@ -55,7 +55,8 @@ class Hardware
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.is_64_bit?
|
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
|
end
|
||||||
|
|
||||||
def self.bits
|
def self.bits
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user