uses: fix `--installed` with outdated versions

With that option iterate only over `Formula.installed`, otherwise
iterate over `Formula`. This is faster than iterating over all the
formulae and checking if it's installed.

Fixes #27259.
Closes #27295.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>