Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 27e2845

Browse files
committed
perf(element_binder): use every rather than reduce
1 parent 0525da8 commit 27e2845

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

lib/core_dom/element_binder.dart

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
part of angular.core.dom_internal;
22

3-
43
class TemplateElementBinder extends ElementBinder {
54
final DirectiveRef template;
65
ViewFactory templateViewFactory;
@@ -15,17 +14,20 @@ class TemplateElementBinder extends ElementBinder {
1514
return _directiveCache = [template];
1615
}
1716

18-
TemplateElementBinder(_perf, _expando, this.template, this.templateBinder, onEvents, childMode)
17+
TemplateElementBinder(_perf, _expando, this.template, this.templateBinder,
18+
onEvents, childMode)
1919
: super(_perf, _expando, null, null, onEvents, childMode);
2020

21-
toString() => "[TemplateElementBinder template:$template]";
21+
String toString() => "[TemplateElementBinder template:$template]";
2222

2323
_registerViewFactory(node, parentInjector, nodeModule) {
2424
assert(templateViewFactory != null);
2525
nodeModule
26-
..factory(ViewPort, (_) => new ViewPort(node, parentInjector.get(NgAnimate)))
26+
..factory(ViewPort, (_) =>
27+
new ViewPort(node, parentInjector.get(NgAnimate)))
2728
..value(ViewFactory, templateViewFactory)
28-
..factory(BoundViewFactory, (Injector injector) => templateViewFactory.bind(injector));
29+
..factory(BoundViewFactory, (Injector injector) =>
30+
templateViewFactory.bind(injector));
2931
}
3032
}
3133

@@ -35,15 +37,13 @@ class TemplateElementBinder extends ElementBinder {
3537
*/
3638
class ElementBinder {
3739
// DI Services
38-
3940
final Profiler _perf;
4041
final Expando _expando;
4142
final Map onEvents;
4243

4344
// Member fields
4445
final decorators;
4546

46-
4747
final DirectiveRef component;
4848

4949
// Can be either COMPILE_CHILDREN or IGNORE_CHILDREN
@@ -83,12 +83,9 @@ class ElementBinder {
8383

8484
var attachDelayStatus = controller is NgAttachAware ? [false] : null;
8585
checkAttachReady() {
86-
// TODO .every may be a better choice.
87-
if (attachDelayStatus.reduce((a, b) => a && b)) {
86+
if (attachDelayStatus.every((a) => a)) {
8887
attachDelayStatus = null;
89-
if (scope.isAttached) {
90-
controller.attach();
91-
}
88+
if (scope.isAttached) controller.attach();
9289
}
9390
}
9491
for (var map in ref.mappings) {
@@ -174,10 +171,9 @@ class ElementBinder {
174171

175172
// Overridden in TemplateElementBinder
176173
_registerViewFactory(node, parentInjector, nodeModule) {
177-
nodeModule
178-
..factory(ViewPort, null)
179-
..factory(ViewFactory, null)
180-
..factory(BoundViewFactory, null);
174+
nodeModule..factory(ViewPort, null)
175+
..factory(ViewFactory, null)
176+
..factory(BoundViewFactory, null);
181177
}
182178

183179
Injector bind(View view, Injector parentInjector, dom.Node node) {
@@ -234,7 +230,7 @@ class ElementBinder {
234230
return nodeInjector;
235231
}
236232

237-
toString() => "[ElementBinder decorators:$decorators]";
233+
String toString() => "[ElementBinder decorators:$decorators]";
238234
}
239235

240236
// Used for walking the DOM
@@ -244,15 +240,16 @@ class ElementBinderTreeRef {
244240

245241
ElementBinderTreeRef(this.offsetIndex, this.subtree);
246242
}
243+
247244
class ElementBinderTree {
248-
ElementBinder binder;
249-
List<ElementBinderTreeRef> subtrees;
245+
final ElementBinder binder;
246+
final List<ElementBinderTreeRef> subtrees;
250247

251248
ElementBinderTree(this.binder, this.subtrees);
252249
}
253250

254251
class TaggedTextBinder {
255-
ElementBinder binder;
252+
final ElementBinder binder;
256253
final int offsetIndex;
257254

258255
TaggedTextBinder(this.binder, this.offsetIndex);

0 commit comments

Comments
 (0)