Yet Another Integer Underflow Bug
Nick Hamann (via David Smith):
However, when
haystack.len()is less than 20,haystack.len() - 20will be a very large number; we have an underflow error on our hands. This bug was causing the code to erroneously use theTwoWaySearcherin general for haystacks of length less than 20, but in particular for the case of"bananas".contains("nana"). The fix is to add20to the needle instead of subtracting it from the haystack […]