| Index: components/query_parser/query_parser.cc
|
| diff --git a/components/query_parser/query_parser.cc b/components/query_parser/query_parser.cc
|
| index b9ac349ebded8e1b4c40250dde1c214cee0ee0da..42a9ad5de4d688b81c152ab67664559d23fc0790 100644
|
| --- a/components/query_parser/query_parser.cc
|
| +++ b/components/query_parser/query_parser.cc
|
| @@ -46,16 +46,6 @@ void CoalesceMatchesFrom(size_t index, Snippet::MatchPositions* matches) {
|
| }
|
| }
|
|
|
| -// Sorts the match positions in |matches| by their first index, then coalesces
|
| -// any match positions that intersect each other.
|
| -void CoalseAndSortMatchPositions(Snippet::MatchPositions* matches) {
|
| - std::sort(matches->begin(), matches->end(), &CompareMatchPosition);
|
| - // WARNING: we don't use iterator here as CoalesceMatchesFrom may remove
|
| - // from matches.
|
| - for (size_t i = 0; i < matches->size(); ++i)
|
| - CoalesceMatchesFrom(i, matches);
|
| -}
|
| -
|
| // Returns true if the character is considered a quote.
|
| bool IsQueryQuote(wchar_t ch) {
|
| return ch == '"' ||
|
| @@ -392,7 +382,7 @@ bool QueryParser::DoesQueryMatch(const base::string16& text,
|
| // completely punt here.
|
| match_positions->clear();
|
| } else {
|
| - CoalseAndSortMatchPositions(&matches);
|
| + SortAndCoalesceMatchPositions(&matches);
|
| match_positions->swap(matches);
|
| }
|
| return true;
|
| @@ -468,9 +458,19 @@ void QueryParser::ExtractQueryWords(const base::string16& text,
|
| words->push_back(QueryWord());
|
| words->back().word = word;
|
| words->back().position = iter.prev();
|
| - }
|
| + }
|
| }
|
| }
|
| }
|
|
|
| +// static
|
| +void QueryParser::SortAndCoalesceMatchPositions(
|
| + Snippet::MatchPositions* matches) {
|
| + std::sort(matches->begin(), matches->end(), &CompareMatchPosition);
|
| + // WARNING: we don't use iterator here as CoalesceMatchesFrom may remove
|
| + // from matches.
|
| + for (size_t i = 0; i < matches->size(); ++i)
|
| + CoalesceMatchesFrom(i, matches);
|
| +}
|
| +
|
| } // namespace query_parser
|
|
|