Performance improvement and benchmark

n/t

cc @bnoordhuis