Commit 85da8ddf authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Adopt unordered containers for bookmark sync

Some users have a huge amount of bookmarks (>100K) and ordered STL
containers can run into performance issues.

To reduce UI jank during browser startup, let's trivially adopt
unordered containers. This can help reduce the time spent in
SyncedBookmarkTracker::InitEntitiesFromModelAndMetadata().

Change-Id: Id789a1d8f0aa14a94aa0974b939568b966be6300
Bug: 1068378
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306253
Auto-Submit: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789917}
parent f772a0aa
......@@ -5,7 +5,6 @@
#include "components/sync_bookmarks/synced_bookmark_tracker.h"
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
......@@ -708,7 +707,7 @@ SyncedBookmarkTracker::ReorderUnsyncedEntitiesExceptDeletions(
// node. What's left in |nodes| are the roots of the forest.
// 3. Start at each root in |nodes|, emit the update and recurse over its
// children.
std::set<const bookmarks::BookmarkNode*> nodes;
std::unordered_set<const bookmarks::BookmarkNode*> nodes;
// Collect nodes with updates
for (const SyncedBookmarkTracker::Entity* entity : entities) {
DCHECK(entity->IsUnsynced());
......
......@@ -5,7 +5,6 @@
#ifndef COMPONENTS_SYNC_BOOKMARKS_SYNCED_BOOKMARK_TRACKER_H_
#define COMPONENTS_SYNC_BOOKMARKS_SYNCED_BOOKMARK_TRACKER_H_
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
......@@ -351,7 +350,8 @@ class SyncedBookmarkTracker {
// A map of sync server ids to sync entities. This should contain entries and
// metadata for almost everything.
std::map<std::string, std::unique_ptr<Entity>> sync_id_to_entities_map_;
std::unordered_map<std::string, std::unique_ptr<Entity>>
sync_id_to_entities_map_;
// A map of bookmark nodes to sync entities. It's keyed by the bookmark node
// pointers which get assigned when loading the bookmark model. This map is
......
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