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

Unified Diff: pkg/mdv/lib/src/template_iterator.dart

Issue 21451002: Speed up CompoundBindings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | pkg/observe/lib/src/compound_binding.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdv/lib/src/template_iterator.dart
diff --git a/pkg/mdv/lib/src/template_iterator.dart b/pkg/mdv/lib/src/template_iterator.dart
index a88a43b5fc24f554f5aee1f630024d39e06ad74c..6c87a42a292d5857171984d7718625e936889447 100644
--- a/pkg/mdv/lib/src/template_iterator.dart
+++ b/pkg/mdv/lib/src/template_iterator.dart
@@ -99,14 +99,12 @@ void _setupBinding(Node node, String name, List tokens, model,
return;
}
- var replacementBinding = new CompoundBinding();
- for (var i = 1; i < tokens.length; i += 2) {
- // TODO(jmesserly): not sure if this index is correct. See my comment here:
- // https://github.com/Polymer/mdv/commit/f1af6fe683fd06eed2a7a7849f01c227db12cda3#L0L1035
- _bindOrDelegate(replacementBinding, i, model, tokens[i], delegate);
- }
-
- replacementBinding.combinator = (values) {
+ // TODO(jmesserly): MDV caches the closure on the tokens, but I'm not sure
+ // why they do that instead of just caching the entire CompoundBinding object
+ // and unbindAll then bind to the new model.
+ var replacementBinding = new CompoundBinding()
+ ..scheduled = true
+ ..combinator = (values) {
var newValue = new StringBuffer();
for (var i = 0, text = true; i < tokens.length; i++, text = !text) {
@@ -123,6 +121,14 @@ void _setupBinding(Node node, String name, List tokens, model,
return newValue.toString();
};
+ for (var i = 1; i < tokens.length; i += 2) {
+ // TODO(jmesserly): not sure if this index is correct. See my comment here:
+ // https://github.com/Polymer/mdv/commit/f1af6fe683fd06eed2a7a7849f01c227db12cda3#L0L1035
+ _bindOrDelegate(replacementBinding, i, model, tokens[i], delegate);
+ }
+
+ replacementBinding.resolve();
+
node.bind(name, replacementBinding, 'value');
}
« no previous file with comments | « no previous file | pkg/observe/lib/src/compound_binding.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698