From 53821be7ccdc5d85cb31082640601a8224a9d8e4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 22 Feb 2016 23:07:29 +0000 Subject: [PATCH] Tweak RankedMatch::operator< --- src/ranked_match.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ranked_match.cc b/src/ranked_match.cc index a36ccdcc4..6ef2b5145 100644 --- a/src/ranked_match.cc +++ b/src/ranked_match.cc @@ -87,10 +87,13 @@ RankedMatch::RankedMatch(StringView candidate, StringView query) bool RankedMatch::operator<(const RankedMatch& other) const { - if (m_only_word_boundary or other.m_only_word_boundary) - return m_only_word_boundary and other.m_only_word_boundary ? - m_word_boundary_match_count > other.m_word_boundary_match_count - : m_only_word_boundary; + if (m_only_word_boundary and other.m_only_word_boundary) + { + if (m_word_boundary_match_count != other.m_word_boundary_match_count) + return m_word_boundary_match_count > other.m_word_boundary_match_count; + } + 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;