(#22363) Add alternative Visitor impl that may prove faster
This adds an alternative Visitor implementation that may prove
to be faster in certain situations. The current benchmarks are
however too simplistic to give a good indication. It seems to be
on par with the previous implementation for simple cases. It is
worth keeping this implementation for later use with larger benchmarks.