Re: [PATCH 4/6] apply: refactor code to drop `line_allocated`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 16, 2024, 18:56 UTC
- Message-ID
- <xmqqldzrmnqn.fsf@gitster.g>
- In-Reply-To
- <0427cb72507bba7ed62d13a5523fea351a0cb35f.1726470385.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> Refactor the function to use memmove(3P) instead, which allows us to get > rid of this double bookkeeping. We call this function at most once per > image anyway, so this shouldn't cause any performance regressions.
Don't we call remove_first_line() as long as leading is larger than trailing repeatedly? Is "at most once" accurate?
As to the correctness, I think nobody takes the address of an element in the line[] array and expects the address to stay valid across a call to remove_first_line(), so this should be safe.
Thanks.
> Signed-off-by: Patrick Steinhardt <ps@pks.im> > --- > apply.c | 33 ++++++++++++++------------------- > 1 file changed, 14 insertions(+), 19 deletions(-)