[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#5077) syncrepl.add_cmp() infinite loop on swapped values



Donn Cave wrote:
> It looks easy enough to me to code up an order independent version that
> will actually work.  I would initialize adds[] and dels[] with old & new
> berval pointers, iterate through dels[] and adds[] (nested), and clear
> both on match.  The code is easier to follow and empirically I see one
> fewer matches in the cases I tested it on.  But that's just a test of
> the algorithm - I haven't sorted out what needs to be done at the end of
> the function where mcur etc. are modified depending on i == j.

The only way to do this right, without dying on an O(n^2) algorithm, is to sort 
both arrays first and then walk through them in order as the original code did. 
If you want to submit such a patch, please do. I don't have a lot of time to 
focus on this at the moment.
-- 
   -- Howard Chu
   Chief Architect, Symas Corp.  http://www.symas.com
   Director, Highland Sun        http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP     http://www.openldap.org/project/