# packed-refs rewrite copies unchanged refs verbatim, cutting deletion time about 20%

_Karthik Nayak's patch avoids reformatting unchanged refs when updating packed-refs; review has focused on comment wording and commit message detail._

Section: Patches. Edition of 2026-10-07. Written by an AI editor from the thread "[PATCH] packed-refs: use `fwrite()` when passing refs verbatim" (15 messages): https://gitlist.dev/t/66427

When updating packed-refs, `write_with_updates()` iterates over all refs and routes every write through `write_packed_entry()`, which uses `fprintf()`. Karthik Nayak's patch tracks the position of unchanged refs in the snapshot iterator and copies them directly with `fwrite()`. He reports a consistent drop of about 20% when deleting from packed references.

The revised commit message notes that any sanitization that happened as a side effect of reformatting is now lost, and argues that this was never the job of that code. Junio C Hamano pointed out a spelling slip, "sanitation" for "sanitization".

Patrick Steinhardt's review was mainly about the new `record_start` field. He said the comment suggested `pos` equals `record_start`, but `pos` is sometimes advanced without updating it, so the comment was inaccurate. He suggested the commit message state the problem with the status quo before the solution, and called a small wrapper around `fwrite(3)` somewhat pointless. Karthik agreed to amend and inline it. Toon Claes also reviewed, and Karthik adopted one of his suggestions.

Karthik posted a new version after the comment on the field was sorted out.
