]> git.ipfire.org Git - thirdparty/git.git/commit
ref: initialize ref name outside of check functions
authorshejialuo <shejialuo@gmail.com>
Wed, 20 Nov 2024 11:51:24 +0000 (19:51 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2024 23:21:32 +0000 (08:21 +0900)
commit56ca6039576294b6efb95345dafe81733bfb61d5
treed977760323b5a13c23624cc1cf455a474ff9fd28
parent32dc1c7ec3c4e92704f221abbfee5cc1d50bf473
ref: initialize ref name outside of check functions

We passes "refs_check_dir" to the "files_fsck_refs_name" function which
allows it to create the checked ref name later. However, when we
introduce a new check function, we have to allocate redundant memory and
re-calculate the ref name. It's bad for us to allocate redundant memory
and duplicate logic. Instead, we should allocate and calculate it only
once and pass the ref name to the check functions.

In order not to do repeat calculation, rename "refs_check_dir" to
"refname". And in "files_fsck_refs_dir", create a new strbuf "refname",
thus whenever we handle a new ref, calculate the name and call the check
functions one by one.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c