Commit 4e71240d authored by Tom Lane's avatar Tom Lane

Now that I look at it, is_stopword() is broken and always has been.

Doesn't anyone remember how to program a binary search??
parent 6d87107b
...@@ -351,10 +351,9 @@ is_stopword(char *text) ...@@ -351,10 +351,9 @@ is_stopword(char *text)
StopLow = &StopWords[0]; /* initialize stuff for binary search */ StopLow = &StopWords[0]; /* initialize stuff for binary search */
StopHigh = endof(StopWords); StopHigh = endof(StopWords);
if (lengthof(StopWords) == 0) /* Loop invariant: *StopLow <= text < *StopHigh */
return false;
while (StopLow <= StopHigh) while (StopLow < StopHigh)
{ {
StopMiddle = StopLow + (StopHigh - StopLow) / 2; StopMiddle = StopLow + (StopHigh - StopLow) / 2;
difference = strcmp(*StopMiddle, text); difference = strcmp(*StopMiddle, text);
...@@ -363,7 +362,7 @@ is_stopword(char *text) ...@@ -363,7 +362,7 @@ is_stopword(char *text)
else if (difference < 0) else if (difference < 0)
StopLow = StopMiddle + 1; StopLow = StopMiddle + 1;
else else
StopHigh = StopMiddle - 1; StopHigh = StopMiddle;
} }
return (false); return (false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment