This is a minor optimization and cleanup. It's mainly to reduce the code size for tests-suite (which is a concern on Kawa due to annoying JVM limitations).
It mostly makes sense to merge this into the reference implementation to reduce
divergence from the Kawa version.