Improve output in the (rare) cases where a tap offers both commands and
formulae or neither. Also adjust code to stay below the 80 column limit.
ClosesHomebrew/homebrew#44995.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
There are plenty of IO operations inside Tap object, and it will be more
when implementing formula alias reverse look up(e.g. list all of alias
names for a formula). So let's cache them.
Some benchmark:
$ time brew info $(brew ruby -e 'puts Formula.tap_names') > /dev/null
Before: 6.40s user 2.42s system 96% cpu 9.134 total
After: 4.75s user 0.77s system 97% cpu 5.637 total
ClosesHomebrew/homebrew#44377.
Signed-off-by: Xu Cheng <xucheng@me.com>