aboutsummaryrefslogtreecommitdiffstats
path: root/diff.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-07 08:37:48 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-07 10:30:48 -0700
commit23c32511b31f2123fd194ba3a89c758ba3e55143 (patch)
tree9115c15635c8fb1f396a2565158578b54afa3886 /diff.c
parentglobal: convert intentionally-leaking config strings to consts (diff)
downloadgit-23c32511b31f2123fd194ba3a89c758ba3e55143.tar.gz
git-23c32511b31f2123fd194ba3a89c758ba3e55143.zip
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>
Diffstat (limited to 'diff.c')
0 files changed, 0 insertions, 0 deletions