Speeds up commiting a single file from ~2.6s to ~1.2s on my machine.
This avoids calling rewritemeta separately, which means parsing all the metadata files once instead of twice. This reduces the running time of the pre-commit script from ~3s to ~2s on my machine.