diff --git a/src/wcstringutil.cpp b/src/wcstringutil.cpp index 7e77740af..d83e3e6cd 100644 --- a/src/wcstringutil.cpp +++ b/src/wcstringutil.cpp @@ -202,25 +202,6 @@ string_fuzzy_match_t string_fuzzy_match_string(const wcstring &string, return result; } -template -static inline int compare_ints(T a, T b) { - if (a < b) return -1; - if (a == b) return 0; - return 1; -} - -/// Compare types; if the types match, compare distances. -int string_fuzzy_match_t::compare(const string_fuzzy_match_t &rhs) const { - if (this->type != rhs.type) { - return compare_ints(this->type, rhs.type); - } else if (this->match_distance_first != rhs.match_distance_first) { - return compare_ints(this->match_distance_first, rhs.match_distance_first); - } else if (this->match_distance_second != rhs.match_distance_second) { - return compare_ints(this->match_distance_second, rhs.match_distance_second); - } - return 0; // equal -} - template size_t ifind_impl(const T &haystack, const T &needle) { using char_t = typename T::value_type; diff --git a/src/wcstringutil.h b/src/wcstringutil.h index 2bc93b606..5e81071d4 100644 --- a/src/wcstringutil.h +++ b/src/wcstringutil.h @@ -111,9 +111,6 @@ struct string_fuzzy_match_t { // Constructor. explicit string_fuzzy_match_t(enum fuzzy_type_t t, size_t distance_first = 0, size_t distance_second = 0); - - // Return -1, 0, 1 if this match is (respectively) better than, equal to, or worse than rhs. - int compare(const string_fuzzy_match_t &rhs) const; }; /// Compute a fuzzy match for a string. If maximum_match is not fuzzy_match_t::none, limit the type diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 91ce154c8..2943cd396 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -851,7 +851,8 @@ void wildcard_expander_t::expand_literal_intermediate_segment_with_fuzz(const wc c->prepend_token_prefix(child_prefix); } // And every match must be made at least as fuzzy as ours. - if (match.compare(c->match) > 0) { + // TODO: justify this, tests do not exercise it yet. + if (match.type > c->match.type) { // Our match is fuzzier. c->match = match; }