Commit 9ba66611 authored by mpearson@chromium.org's avatar mpearson@chromium.org

Omnibox: append old matches, don't attempt to insert them

Make AddMatch() append old matches rather than attempt to insert them
in order.  We call SortAndCull() after AddMatch() in the only code
path that uses AddMatch(), so the order doesn't matter.

Then eliminate AddMatch() because the revised version is short,
instead inlining the few things it still does in its only caller.

In some quick interactive testing, I didn't notice any problems.

The autocomplete_result tests still pass also.  (That said, I don't
think we test CopyOldMatches that extensively in it.)

BUG=380357

Review URL: https://codereview.chromium.org/329783003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276714 0039d316-1c4b-4281-b951-d872f2087c98
parent dd49d9c1
...@@ -406,23 +406,6 @@ void AutocompleteResult::CopyFrom(const AutocompleteResult& rhs) { ...@@ -406,23 +406,6 @@ void AutocompleteResult::CopyFrom(const AutocompleteResult& rhs) {
alternate_nav_url_ = rhs.alternate_nav_url_; alternate_nav_url_ = rhs.alternate_nav_url_;
} }
void AutocompleteResult::AddMatch(
AutocompleteInput::PageClassification page_classification,
const AutocompleteMatch& match) {
DCHECK(default_match_ != end());
DCHECK_EQ(AutocompleteMatch::SanitizeString(match.contents), match.contents);
DCHECK_EQ(AutocompleteMatch::SanitizeString(match.description),
match.description);
CompareWithDemoteByType comparing_object(page_classification);
ACMatches::iterator insertion_point =
std::upper_bound(begin(), end(), match, comparing_object);
matches_difference_type default_offset = default_match_ - begin();
if ((insertion_point - begin()) <= default_offset)
++default_offset;
matches_.insert(insertion_point, match);
default_match_ = begin() + default_offset;
}
void AutocompleteResult::BuildProviderToMatches( void AutocompleteResult::BuildProviderToMatches(
ProviderToMatches* provider_to_matches) const { ProviderToMatches* provider_to_matches) const {
for (ACMatches::const_iterator i(begin()); i != end(); ++i) for (ACMatches::const_iterator i(begin()); i != end(); ++i)
...@@ -461,7 +444,7 @@ void AutocompleteResult::MergeMatchesByProvider( ...@@ -461,7 +444,7 @@ void AutocompleteResult::MergeMatchesByProvider(
AutocompleteMatch match = *i; AutocompleteMatch match = *i;
match.relevance = std::min(max_relevance, match.relevance); match.relevance = std::min(max_relevance, match.relevance);
match.from_previous = true; match.from_previous = true;
AddMatch(page_classification, match); matches_.push_back(match);
delta--; delta--;
} }
} }
......
...@@ -175,12 +175,6 @@ class AutocompleteResult { ...@@ -175,12 +175,6 @@ class AutocompleteResult {
// operator=() by another name. // operator=() by another name.
void CopyFrom(const AutocompleteResult& rhs); void CopyFrom(const AutocompleteResult& rhs);
// Adds a single match. The match is inserted at the appropriate position
// based on relevancy and display order. This is ONLY for use after
// SortAndCull() has been invoked, and preserves default_match_.
void AddMatch(AutocompleteInput::PageClassification page_classification,
const AutocompleteMatch& match);
// Populates |provider_to_matches| from |matches_|. // Populates |provider_to_matches| from |matches_|.
void BuildProviderToMatches(ProviderToMatches* provider_to_matches) const; void BuildProviderToMatches(ProviderToMatches* provider_to_matches) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment