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

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: Remove cbegin/cend references to fix compile 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') | sync/syncable/directory.h » ('J')
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 1e1513b1b7bf0c2bf74b116c1783230dbfcad77c..cbc58df409d087aa7a81afe4529ab77020a32f66 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') | sync/syncable/directory.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698