OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/query_parser/query_parser.h" | 5 #include "components/query_parser/query_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
11 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" |
13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 | 16 |
16 namespace query_parser { | 17 namespace query_parser { |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Returns true if |mp1.first| is less than |mp2.first|. This is used to | 20 // Returns true if |mp1.first| is less than |mp2.first|. This is used to |
20 // sort match positions. | 21 // sort match positions. |
21 int CompareMatchPosition(const Snippet::MatchPosition& mp1, | 22 int CompareMatchPosition(const Snippet::MatchPosition& mp1, |
22 const Snippet::MatchPosition& mp2) { | 23 const Snippet::MatchPosition& mp2) { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 void QueryParser::SortAndCoalesceMatchPositions( | 476 void QueryParser::SortAndCoalesceMatchPositions( |
476 Snippet::MatchPositions* matches) { | 477 Snippet::MatchPositions* matches) { |
477 std::sort(matches->begin(), matches->end(), &CompareMatchPosition); | 478 std::sort(matches->begin(), matches->end(), &CompareMatchPosition); |
478 // WARNING: we don't use iterator here as CoalesceMatchesFrom may remove | 479 // WARNING: we don't use iterator here as CoalesceMatchesFrom may remove |
479 // from matches. | 480 // from matches. |
480 for (size_t i = 0; i < matches->size(); ++i) | 481 for (size_t i = 0; i < matches->size(); ++i) |
481 CoalesceMatchesFrom(i, matches); | 482 CoalesceMatchesFrom(i, matches); |
482 } | 483 } |
483 | 484 |
484 } // namespace query_parser | 485 } // namespace query_parser |
OLD | NEW |