Yes but ...
Please read my reply again. It is no less scalable than yours. It just
works out what group of rows need to be hidden/unhidden and does them all
with one command (each - three in total), rather than lots.
I wasn't suggesting you not scan, just that you record the information and
submit fewer hide/show commands.