git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6d87107)
Now that I look at it, is_stopword() is broken and always has been.
Tue, 4 Jul 2000 06:29:27 +0000 (06:29 +0000)
Tue, 4 Jul 2000 06:29:27 +0000 (06:29 +0000)
Doesn't anyone remember how to program a binary search??


diff --git a/contrib/fulltextindex/fti.c b/contrib/fulltextindex/fti.c
index be4522321d7a2149f0148f46dbcaec394929d970..a98fcd47dc7a86be4d71f0552f4d75021b5a198f 100644 (file)
--- a/contrib/fulltextindex/fti.c
+++ b/contrib/fulltextindex/fti.c
@@ -351,10 +351,9 @@ is_stopword(char *text)
StopLow = &StopWords[0]; /* initialize stuff for binary search */
StopHigh = endof(StopWords);
- if (lengthof(StopWords) == 0)
- return false;
+ /* Loop invariant: *StopLow <= text < *StopHigh */
- while (StopLow <= StopHigh)
+ while (StopLow < StopHigh)
{
StopMiddle = StopLow + (StopHigh - StopLow) / 2;
difference = strcmp(*StopMiddle, text);
@@ -363,7 +362,7 @@ is_stopword(char *text)
else if (difference < 0)
StopLow = StopMiddle + 1;
else
- StopHigh = StopMiddle - 1;
+ StopHigh = StopMiddle;
}
return (false);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /