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

Unified Diff: sync/internal_api/base_node.cc

Issue 15322003: sync: Count nodes more efficiently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement suggestions from review Created 7 years, 7 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
« no previous file with comments | « no previous file | sync/syncable/directory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/base_node.cc
diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc
index 88dec8cbd36f474241e3a21fe65cf146d50dde6c..bc9443d3f7af17117ea7a01de29540ad9eed3ac8 100644
--- a/sync/internal_api/base_node.cc
+++ b/sync/internal_api/base_node.cc
@@ -216,31 +216,7 @@ int64 BaseNode::GetFirstChildId() const {
}
int BaseNode::GetTotalNodeCount() const {
- syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans();
-
- int count = 1; // Start with one to include the node itself.
-
- std::stack<int64> stack;
- stack.push(GetFirstChildId());
- while (!stack.empty()) {
- int64 handle = stack.top();
- stack.pop();
- if (handle == kInvalidId)
- continue;
- count++;
- syncable::Entry entry(trans, syncable::GET_BY_HANDLE, handle);
- if (!entry.good())
- continue;
- syncable::Id successor_id = entry.GetSuccessorId();
- if (!successor_id.IsRoot())
- stack.push(IdToMetahandle(trans, successor_id));
- if (!entry.Get(syncable::IS_DIR))
- continue;
- syncable::Id child_id = entry.GetFirstChildId();
- if (!child_id.IsRoot())
- stack.push(IdToMetahandle(trans, child_id));
- }
- return count;
+ return GetEntry()->GetTotalNodeCount();
}
DictionaryValue* BaseNode::GetSummaryAsValue() const {
« no previous file with comments | « no previous file | sync/syncable/directory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698