subsequence_in_string: fix broken optimization

haystack.size() > haystack.size() is always false

change it to needle.size() > haystack.size() as seems intended
This commit is contained in:
Aaron Gyes 2022-12-29 01:02:44 -08:00
parent 21c09c392b
commit 7340761b21

View File

@ -120,8 +120,8 @@ bool string_suffixes_string_case_insensitive(const wcstring &proposed_suffix,
/// Returns true if needle, represented as a subsequence, is contained within haystack.
/// Note subsequence is not substring: "foo" is a subsequence of "follow" for example.
static bool subsequence_in_string(const wcstring &needle, const wcstring &haystack) {
// Impossible if haystack is larger than string.
if (haystack.size() > haystack.size()) {
// Impossible if needle is larger than haystack.
if (needle.size() > haystack.size()) {
return false;
}