[instancer-solver] Port optimization from upstream Fixes https://github.com/harfbuzz/harfbuzz/issues/4291