X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=results.c;h=4e7b4ec0b62751dbeef8e4f8dd6cadfdcb321996;hb=df5fdb22632be887ecd9f5c46a014e7e970148a2;hp=82013cb6218e9896d4256a97b49f513eba57b640;hpb=ac8720a930e5757a72f73e80aff7a988b0082831;p=SXSI%2Fxpathcomp.git diff --git a/results.c b/results.c index 82013cb..4e7b4ec 100644 --- a/results.c +++ b/results.c @@ -45,15 +45,13 @@ void freeResults (results R) static int conv (int p, int n, int lgn) { int t = n+1-(1<>1; + return (p < t) ? p : (p+t)>>1; } int readResult (results R, int p) // returns 0 or 1 @@ -205,8 +203,7 @@ int nextResult (results R, int p) // returns pos of next(p) or -1 if none { int answ; if (((p+1)<<1) > R.n) return -1; // next(last), p+1 out of bounds answ = nextLarger(R.tree,R.n,conv(p+1,R.n,R.lgn),0,R.lgn); - if (answ == -1) return -1; - return unconv(answ,R.n,R.lgn); + return (answ == -1) ? -1 : unconv(answ,R.n,R.lgn); } // Naively implemented by kim