March 9, 2006
10:47 a.m.
On Wed, Mar 08, 2006 at 11:15:02PM -0800, Paul Eggert wrote:
! int lo = 1; [snip] ! if (lo <= i && i < hi) { ! if (t < sp->ats[i]) { ! if (sp->ats[i - 1] <= t) ! goto found; ! i--; ! if (sp->ats[i - 1] <= t) ! goto found; [snip] ! found: ! guess = i; i = (int) sp->types[i - 1];
If i == lo (== 1), and the first <=t test fails, then i==0 and we're accessing sp->ats[-1] and sp->types[-1]. This can be fixed, but as Paul said:
it's quite a bit of complexity for not much benefit, and think I'd prefer the simple binary search.
Me too. --Ken Pizzini