git/refs
Patrick Steinhardt 23c32511b3 refs/reftable: stop micro-optimizing refname allocations on copy
When copying refs, we execute `write_copy_table()` to write the new
table. As the names are given to us via `arg->newname` and
`arg->oldname`, respectively, we optimize away some allocations by
assigning those fields to the reftable records we are about to write
directly, without duplicating them. This requires us to cast the input
to `char *` pointers as they are in fact constant strings. Later on, we
then unset the refname for all of the records before calling
`reftable_log_record_release()` on them.

We also do this when assigning the "HEAD" constant, but here we do not
cast because its type is `char[]` by default. It's about to be turned
into `const char *` though once we enable `-Wwrite-strings` and will
thus cause another warning.

It's quite dubious whether this micro-optimization really helps. We're
about to write to disk anyway, which is going to be way slower than a
small handful of allocations. Let's drop the optimization altogther and
instead copy arguments to simplify the code and avoid the future warning
with `-Wwrite-strings`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-06-07 10:30:48 -07:00
..
debug.c refs: remove create_symref and associated dead code 2024-05-07 08:51:50 -07:00
files-backend.c Merge branch 'ps/pseudo-ref-terminology' 2024-05-28 11:17:06 -07:00
iterator.c refs: always treat iterators as ordered 2024-02-21 09:58:06 -08:00
packed-backend.c refs: remove create_symref and associated dead code 2024-05-07 08:51:50 -07:00
packed-backend.h Revert "Merge branch 'ps/avoid-unnecessary-hook-invocation-with-packed-refs'" 2022-04-13 15:51:33 -07:00
ref-cache.c refs: always treat iterators as ordered 2024-02-21 09:58:06 -08:00
ref-cache.h hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
refs-internal.h refs: remove create_symref and associated dead code 2024-05-07 08:51:50 -07:00
reftable-backend.c refs/reftable: stop micro-optimizing refname allocations on copy 2024-06-07 10:30:48 -07:00