Re: [PATCH] fix diff-delta bad memory access

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Junio C Hamano <junkio@...>, <git@...>, Randal L. Schwartz <merlyn@...>, Alex Riesen <raa.lkml@...>
Date: Wednesday, May 10, 2006 - 3:43 pm

On Wed, 10 May 2006, Linus Torvalds wrote:


Possible.


Yes, ptr points to the last byte of the window for given hash value.

This is so because in the matching loop the window is scrolled byte by 
byte and the new hash value is always made of ROBIN_WINDOW-1 bytes which 
already have been processed (most probably added as literal bytes in the 
delta buffer) plus one new byte.  So it makes sense to start forward 
byte matching only from that last byte to find the longest source area 
to match, especially since all the other bytes in the window are likely 
to be identical already and comparing them repeatedly for entries with 
the same hash would be wasteful in most cases.

Further down, once the best offset with the longest match in the source 
buffer has been found, backward matching is performed to remove as much 
literal bytes that were added to the delta output as possible, which is 
most likely to catch the whole Robin window that hasn't been compared 
previously, but in that case the window content is compared only once.

And the reason why the reference hash is computed with an offset of 1 to 
RABIN_WINDOW inclusive in create_delta_index() is to allow for quick 
initialization of the Rabin window _outside_ of the main loop in 
create_delta().  There is a comment to that effect near the top of 
create_delta_index but probably a small reminder should be added in the 
index loop as well.


Nicolas
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 12:26 pm)
Re: [PATCH] fix diff-delta bad memory access, Linus Torvalds, (Wed May 10, 1:00 pm)
Re: [PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 1:27 pm)
Re: [PATCH] fix diff-delta bad memory access, Linus Torvalds, (Wed May 10, 3:01 pm)
Re: [PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 3:43 pm)
Re: [PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 3:57 pm)
Re: [PATCH] fix diff-delta bad memory access, Linus Torvalds, (Wed May 10, 1:18 pm)