Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: components/history/core/browser/history_types.cc

Issue 2906953003: Remove ScopedVector usage from components/history (Closed)
Patch Set: Remove ScopedVector usage from components/history Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/history_types.cc
diff --git a/components/history/core/browser/history_types.cc b/components/history/core/browser/history_types.cc
index 93a242a2f0cb2990077aa1f58a3182bde58ab385..1624e636b2ad60b4d51938a33995f34272b90470 100644
--- a/components/history/core/browser/history_types.cc
+++ b/components/history/core/browser/history_types.cc
@@ -55,18 +55,18 @@ const size_t* QueryResults::MatchesForURL(const GURL& url,
}
void QueryResults::Swap(QueryResults* other) {
- std::swap(first_time_searched_, other->first_time_searched_);
std::swap(reached_beginning_, other->reached_beginning_);
results_.swap(other->results_);
url_to_results_.swap(other->url_to_results_);
}
-void QueryResults::AppendURLBySwapping(URLResult* result) {
- URLResult* new_result = new URLResult;
- new_result->SwapResult(result);
+void QueryResults::SetURLResults(std::vector<URLResult>&& results) {
+ results_ = std::move(results);
- results_.push_back(new_result);
- AddURLUsageAtIndex(new_result->url(), results_.size() - 1);
+ // Recreate the map for the results_ has been replaced.
+ url_to_results_.clear();
+ for(size_t i = 0; i < results_.size(); ++i)
+ AddURLUsageAtIndex(results_[i].url(), i);
}
void QueryResults::DeleteURL(const GURL& url) {
@@ -83,7 +83,7 @@ void QueryResults::DeleteRange(size_t begin, size_t end) {
// were modified. We will delete references to these later.
std::set<GURL> urls_modified;
for (size_t i = begin; i <= end; i++) {
- urls_modified.insert(results_[i]->url());
+ urls_modified.insert(results_[i].url());
}
// Now just delete that range in the vector en masse (the STL ending is
« no previous file with comments | « components/history/core/browser/history_types.h ('k') | components/history/core/browser/history_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698