reftable/record: introduce function to compare records by key
commitadb5d2cbe9a0589540ca631fb42e1579e8ee2d60
authorPatrick Steinhardt <ps@pks.im>
Mon, 12 Feb 2024 08:32:25 +0000 (12 09:32 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Feb 2024 17:18:04 +0000 (12 09:18 -0800)
treebc957984242e87c8ebd1ffb3cc19256bd3f19622
parentbc7ee2e5e16f0d1e710ef8fab3db59ab11f2bbe7
reftable/record: introduce function to compare records by key

In some places we need to sort reftable records by their keys to
determine their ordering. This is done by first formatting the keys into
a `struct strbuf` and then using `strbuf_cmp()` to compare them. This
logic is needlessly roundabout and can end up costing quite a bit of CPU
cycles, both due to the allocation and formatting logic.

Introduce a new `reftable_record_cmp()` function that knows how to
compare two records with each other without requiring allocations.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/record.c
reftable/record.h