On May 7, 2008, at 3:13 PM, Miguel DeAvila wrote:

On Wednesday 07 May 2008 14:37:16 Michael D'Agosta wrote:
Haven't tried the patch yet (waiting on my app changes to crash :) ), and am beginning to read through assoc.c, naively wondering if the lookahead patch will work as expected. If I understand right, both the lookahead and it pointers are moving targets, and would only detect local loops 2 deep. Wouldn't you want to
save an orig for comparing to lookahead?

I went down this road myself ... the trick is that the lookahead pointer increments two items for every since increment of the it pointer. If a loop exists then the lookahead
pointer will eventually wrap around and catch up with the it pointer.

That is right. This is an lightweight (and safe) loop detection, since it will detect loops within a linked list. Imagine if you have the list: "A-B-C-D-E-F-C". If you save the A or B pointer and use that one to compare with, you will never detect a loop...

Trond

Reply via email to