Cache Tty.width, since it is used heavily because of ohai.

This commit is contained in:
Markus Reiter 2018-06-14 22:14:46 +02:00
parent 502b393d66
commit 13d9305fad

View File

@ -6,10 +6,12 @@ module Tty
end end
def width def width
width = `/bin/stty size 2>/dev/null`.split[1] @width ||= begin
width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero? width = `/bin/stty size 2>/dev/null`.split[1]
width ||= 80 width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
width.to_i width ||= 80
width.to_i
end
end end
def truncate(string) def truncate(string)