From 761d316af672bf38ad87124c4baafb621fe3cf23 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Mar 2016 13:30:54 +0000 Subject: [PATCH] Tweak RankedMatch ordering, give priority to prefix matches --- src/ranked_match.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ranked_match.cc b/src/ranked_match.cc index 11486047..aacf3cae 100644 --- a/src/ranked_match.cc +++ b/src/ranked_match.cc @@ -91,6 +91,9 @@ RankedMatch::RankedMatch(StringView candidate, StringView query) bool RankedMatch::operator<(const RankedMatch& other) const { + if (m_prefix != other.m_prefix) + return m_prefix; + if (m_first_char_match != other.m_first_char_match) return m_first_char_match; @@ -102,9 +105,6 @@ bool RankedMatch::operator<(const RankedMatch& other) const else if (m_only_word_boundary or other.m_only_word_boundary) return m_only_word_boundary; - if (m_prefix != other.m_prefix) - return m_prefix; - if (m_word_boundary_match_count != other.m_word_boundary_match_count) return m_word_boundary_match_count > other.m_word_boundary_match_count;