reftable/block: reuse compressed arrayps/reftable-write-optim
commitfa74f32291d0e2b642345d25e16724567f9b881f
authorPatrick Steinhardt <ps@pks.im>
Mon, 8 Apr 2024 12:24:40 +0000 (8 14:24 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Apr 2024 00:01:42 +0000 (8 17:01 -0700)
treef2829e0f07dc6c740ee080d72036f955284c8faf
parenta155ab2bf4e16b8fe1e0644d9d57d2c62eecd452
reftable/block: reuse compressed array

Similar to the preceding commit, let's reuse the `compressed` array that
we use to store compressed data in. This results in a small reduction in
memory allocations when writing many refs.

Before:

  HEAP SUMMARY:
      in use at exit: 671,931 bytes in 151 blocks
    total heap usage: 22,620,528 allocs, 22,620,377 frees, 1,245,549,984 bytes allocated

After:

  HEAP SUMMARY:
      in use at exit: 671,931 bytes in 151 blocks
    total heap usage: 22,618,257 allocs, 22,618,106 frees, 1,236,351,528 bytes allocated

So while the reduction in allocations isn't really all that big, it's a
low hanging fruit and thus there isn't much of a reason not to pick it.

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