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

Unified Diff: sky/framework/fn.dart

Issue 1051913002: [Effen] use the fact that the parent knows its depth already to avoid walking the entire tree each … (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/fn.dart
diff --git a/sky/framework/fn.dart b/sky/framework/fn.dart
index 65d22e86f699bc00a0359b63358ee52ef5e8177d..20a8b1cffac8f26e8ddf0d4eb3b09f6a79a03205 100644
--- a/sky/framework/fn.dart
+++ b/sky/framework/fn.dart
@@ -75,7 +75,6 @@ abstract class UINode {
UINode _parent;
sky.Node _root;
bool _defunct = false;
- int _nodeDepth;
UINode({ Object key }) {
_key = key == null ? "$runtimeType" : "$runtimeType-$key";
@@ -92,14 +91,11 @@ abstract class UINode {
_root = null;
}
+ int _nodeDepth;
void _ensureDepth() {
if (_nodeDepth == null) {
- _nodeDepth = 0;
- UINode parent = _parent;
- while (parent != null) {
- _nodeDepth++;
- parent = parent._parent;
- }
+ _parent.ensureDepth();
+ _nodeDepth = _parent._nodeDepth + 1;
}
}
@@ -108,13 +104,7 @@ abstract class UINode {
return;
_ensureDepth();
- StringBuffer buffer = new StringBuffer();
- int depth = _nodeDepth;
- while (depth-- > 0) {
- buffer.write(' ');
- }
- buffer.write(message);
- print(buffer);
+ print((' ' * _nodeDepth) + message);
}
void _traceSync(_SyncOperation op, String key) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698