Re: [PATCH 4/6] copy vs rename detection: avoid unnecessary O(n*m) loops
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Oct 26, 2007, 23:36 UTC
- Message-ID
- <alpine.LFD.0.999.0710261633090.30120@woody.linux-foundation.org>
- In-Reply-To
- <7vy7dpv4ls.fsf@gitster.siamese.dyndns.org>
On Fri, 26 Oct 2007, Junio C Hamano wrote:
> > So for a broken pair, the actual value of rename_used does not really > matter. We only care about it not going down to zero.
Correct. The rename_used count really is immaterial *except* for the magic distinction between zero ("it's a rename, no original source file left") and non-zero ("it's a copy, original source file remains").
Which is why the new counter is so fundamentally simple: by decrementing it for each rename we encounter, we automatically get that behaviour of "only the last user turns into a 'rename' if the source file really went away" that we want.
The old code did it all with some really expensive loops over the remaining renames.
Linus