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

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

Issue 1105413002: Avoid conversion of index to BookmarkNode pointer unnacessarily. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 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_model.cc
diff --git a/components/bookmarks/browser/bookmark_model.cc b/components/bookmarks/browser/bookmark_model.cc
index 10d5b2f24ea2dbd107fa88b87dd84bfa34cc30ed..2e174dbedc63314fc2de85d1accdda9582439c90 100644
--- a/components/bookmarks/browser/bookmark_model.cc
+++ b/components/bookmarks/browser/bookmark_model.cc
@@ -188,12 +188,13 @@ void BookmarkModel::EndGroupedChanges() {
GroupedBookmarkChangesEnded(this));
}
-void BookmarkModel::Remove(const BookmarkNode* parent, int index) {
- if (!loaded_ || !IsValidIndex(parent, index, false) || is_root_node(parent)) {
+void BookmarkModel::Remove(const BookmarkNode* node) {
+ DCHECK(node);
+ if (!loaded_ || is_root_node(node)) {
NOTREACHED();
return;
}
- RemoveAndDeleteNode(AsMutable(parent->GetChild(index)));
+ RemoveAndDeleteNode(AsMutable(node));
}
void BookmarkModel::RemoveAllUserBookmarks() {
@@ -847,6 +848,7 @@ void BookmarkModel::RemoveAndDeleteNode(BookmarkNode* delete_me) {
const BookmarkNode* parent = node->parent();
DCHECK(parent);
int index = parent->GetIndexOf(node.get());
+ DCHECK_NE(-1, index);
FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
OnWillRemoveBookmarks(this, parent, index, node.get()));
« no previous file with comments | « components/bookmarks/browser/bookmark_model.h ('k') | components/bookmarks/browser/bookmark_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698