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

Unified Diff: components/bookmarks/browser/bookmark_expanded_state_tracker.cc

Issue 2838893002: Remove base::ListValue::Set(size_t, base::Value*) (Closed)
Patch Set: Fix Compilation Error Created 3 years, 8 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/bookmarks/browser/bookmark_expanded_state_tracker.cc
diff --git a/components/bookmarks/browser/bookmark_expanded_state_tracker.cc b/components/bookmarks/browser/bookmark_expanded_state_tracker.cc
index dd3070b039c2c2d99d836812e3b0f03d02bb3b97..d0c6b4571de242fa770bce6ae19417aff10c8b49 100644
--- a/components/bookmarks/browser/bookmark_expanded_state_tracker.cc
+++ b/components/bookmarks/browser/bookmark_expanded_state_tracker.cc
@@ -6,6 +6,9 @@
#include <stdint.h>
+#include <utility>
+#include <vector>
+
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "components/bookmarks/browser/bookmark_model.h"
@@ -104,13 +107,14 @@ void BookmarkExpandedStateTracker::UpdatePrefs(const Nodes& nodes) {
if (!pref_service_)
return;
- base::ListValue values;
- for (Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
- values.Set(values.GetSize(),
- new base::Value(base::Int64ToString((*i)->id())));
+ std::vector<base::Value> values;
+ values.reserve(nodes.size());
+ for (const auto* node : nodes) {
+ values.emplace_back(base::Int64ToString(node->id()));
}
- pref_service_->Set(prefs::kBookmarkEditorExpandedNodes, values);
+ pref_service_->Set(prefs::kBookmarkEditorExpandedNodes,
+ base::Value(std::move(values)));
}
} // namespace bookmarks

Powered by Google App Engine
This is Rietveld 408576698