Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Don't explicitly return null in non host view build methods.
Browse files Browse the repository at this point in the history
dart2js compiles an explicit `return null` to `return`, but the implied return null to nothing. These behave the same but the latter results in a smaller JS output.

I thought I might need to add an \\ ignore: MISSING_RETURN comment to avoid hints, but there don't appear to be any new ones.

PiperOrigin-RevId: 211659339
  • Loading branch information
hellyhansen authored and matanlurey committed Sep 10, 2018
1 parent c697da6 commit 7e62eff
Show file tree
Hide file tree
Showing 39 changed files with 9 additions and 155 deletions.
7 changes: 0 additions & 7 deletions _goldens/test/_files/change_detection.template.golden
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class ViewCheckOnceComponent0 extends AppView<import1.CheckOnceComponent> {
final _text_1 = import5.Text('CheckOnce');
_el_0.append(_text_1);
init(const [], null);
return null;
}

void detectHostChanges(bool firstCheck) {
Expand Down Expand Up @@ -109,7 +108,6 @@ class ViewCheckedComponent0 extends AppView<import1.CheckedComponent> {
final _text_1 = import5.Text('Checked');
_el_0.append(_text_1);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -171,7 +169,6 @@ class ViewCheckAlwaysComponent0 extends AppView<import1.CheckAlwaysComponent> {
final _text_1 = import5.Text('CheckAlways');
_el_0.append(_text_1);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -233,7 +230,6 @@ class ViewDetachedComponent0 extends AppView<import1.DetachedComponent> {
final _text_1 = import5.Text('Detached');
_el_0.append(_text_1);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -295,7 +291,6 @@ class ViewOnPushComponent0 extends AppView<import1.OnPushComponent> {
final _text_1 = import5.Text('OnPush');
_el_0.append(_text_1);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -359,7 +354,6 @@ class ViewStatefulComponent0 extends AppView<import1.StatefulComponent> {
_el_0.append(_text_1);
init(const [], null);
_ctx.stateChangeCallback = markStateChanged;
return null;
}
}

Expand Down Expand Up @@ -421,7 +415,6 @@ class ViewDefaultComponent0 extends AppView<import1.DefaultComponent> {
final _text_1 = import5.Text('Default');
_el_0.append(_text_1);
init(const [], null);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ViewTestComponent0 extends AppView<import1.TestComponent> {
final _rootEl = rootEl;
final import5.HtmlElement parentRenderNode = initViewRoot(_rootEl);
init(const [], null);
return null;
}
}

Expand Down
2 changes: 0 additions & 2 deletions _goldens/test/_files/core_directives.template.golden
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class ViewTestFooComponent0 extends AppView<import1.TestFooComponent> {
TemplateRef _TemplateRef_1_8 = TemplateRef(_appEl_1, viewFactory_TestFooComponent2);
_NgFor_1_9 = import4.NgFor(_appEl_1, _TemplateRef_1_8);
init([], null);
return null;
}

@override
Expand Down Expand Up @@ -101,7 +100,6 @@ class _ViewTestFooComponent2 extends AppView<import1.TestFooComponent> {
_el_1.append(_text_2);
_el_1.addEventListener('click', eventHandler1(_handle_click_1_0));
init0(_el_0);
return null;
}

@override
Expand Down
12 changes: 0 additions & 12 deletions _goldens/test/_files/dart2js/dart2js_golden.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9441,7 +9441,6 @@
this._ComponentConditionalFeatures_4_5 = t1;
this._compView_4.create$2(0, t1, []);
this.init$2(C.List_empty, null);
return;
},
detectChangesInternal$0: function() {
if (this.viewData._cdState === 0) {
Expand Down Expand Up @@ -9517,7 +9516,6 @@
var parentRenderNode = this.initViewRoot$1(this.rootEl);
this._el_0 = S.createAndAppend(document, "default-change-detection-and-input", parentRenderNode);
this.init$2(C.List_empty, null);
return;
},
detectChangesInternal$0: function() {
this.ctx.name;
Expand All @@ -9535,7 +9533,6 @@
this._anchor_0 = t1;
parentRenderNode.appendChild(t1);
this.init$2([], null);
return;
},
detectChangesInternal$0: function() {
this.ctx.showDiv;
Expand All @@ -9560,7 +9557,6 @@
this._appEl_0 = t1;
this._NgIf_0_9 = new K.NgIf(new D.TemplateRef(t1, N.dart2js_golden_template__viewFactory_EmbeddedNgIf1$closure()), t1, false);
this.init$2(C.List_empty, null);
return;
},
detectChangesInternal$0: function() {
var _ctx = this.ctx;
Expand Down Expand Up @@ -9597,7 +9593,6 @@
this._NullComponent_0_5 = t2;
t1.create$2(0, t2, []);
this.init0$1(this._el_0);
return;
},
detectChangesInternal$0: function() {
this._compView_0.detectChanges$0();
Expand All @@ -9616,7 +9611,6 @@
build$0: function() {
this.initViewRoot$1(this.rootEl);
this.init$2(C.List_empty, null);
return;
},
$asAppView: function() {
return [E.NullComponent];
Expand All @@ -9627,7 +9621,6 @@
build$0: function() {
this.initViewRoot$1(this.rootEl);
this.init$2(C.List_empty, null);
return;
},
$asAppView: function() {
return [E.InjectsFromArbitraryParent];
Expand All @@ -9650,7 +9643,6 @@
this._appEl_1 = t1;
this._NgIf_1_9 = new K.NgIf(new D.TemplateRef(t1, N.dart2js_golden_template__viewFactory_ComponentConditionalFeatures2$closure()), t1, false);
this.init$2(C.List_empty, null);
return;
},
detectChangesInternal$0: function() {
var _ctx, t1;
Expand Down Expand Up @@ -9695,7 +9687,6 @@
this._FeatureA_0_5 = t2;
t1.create$2(0, t2, []);
this.init0$1(this._el_0);
return;
},
detectChangesInternal$0: function() {
this._compView_0.detectChanges$0();
Expand Down Expand Up @@ -9730,7 +9721,6 @@
this._FeatureB_0_5 = t2;
t1.create$2(0, t2, []);
this.init0$1(this._el_0);
return;
},
detectChangesInternal$0: function() {
this._compView_0.detectChanges$0();
Expand All @@ -9749,7 +9739,6 @@
build$0: function() {
this.initViewRoot$1(this.rootEl).appendChild(document.createTextNode("I am Feature A"));
this.init$2(C.List_empty, null);
return;
},
$asAppView: function() {
return [E.FeatureA];
Expand All @@ -9760,7 +9749,6 @@
build$0: function() {
this.initViewRoot$1(this.rootEl).appendChild(document.createTextNode("I am Feature B"));
this.init$2(C.List_empty, null);
return;
},
$asAppView: function() {
return [E.FeatureB];
Expand Down
13 changes: 0 additions & 13 deletions _goldens/test/_files/dart2js/dart2js_golden.template.golden
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class ViewRootComponent0 extends AppView<import1.RootComponent> {
_ComponentConditionalFeatures_4_5 = import1.ComponentConditionalFeatures();
_compView_4.create(_ComponentConditionalFeatures_4_5, []);
init(const [], null);
return null;
}

@override
Expand Down Expand Up @@ -169,7 +168,6 @@ class ViewUsesDefaultChangeDetectionAndInput0 extends AppView<import1.UsesDefaul
var doc = import2.document;
_el_0 = createAndAppend(doc, 'default-change-detection-and-input', parentRenderNode);
init(const [], null);
return null;
}

@override
Expand Down Expand Up @@ -243,7 +241,6 @@ class ViewDefaultChangeDetectionAndInput0 extends AppView<import1.DefaultChangeD
_text_1 = import2.Text('');
parentRenderNode.append(_text_1);
init(const [], null);
return null;
}

@override
Expand Down Expand Up @@ -317,7 +314,6 @@ class ViewInlinedNgIf0 extends AppView<import1.InlinedNgIf> {
_anchor_0 = createViewContainerAnchor();
parentRenderNode.append(_anchor_0);
init([], null);
return null;
}

@override
Expand Down Expand Up @@ -400,7 +396,6 @@ class ViewEmbeddedNgIf0 extends AppView<import1.EmbeddedNgIf> {
TemplateRef _TemplateRef_0_8 = TemplateRef(_appEl_0, viewFactory_EmbeddedNgIf1);
_NgIf_0_9 = NgIf(_appEl_0, _TemplateRef_0_8);
init(const [], null);
return null;
}

@override
Expand Down Expand Up @@ -434,7 +429,6 @@ class _ViewEmbeddedNgIf1 extends AppView<import1.EmbeddedNgIf> {
_NullComponent_0_5 = import1.NullComponent();
_compView_0.create(_NullComponent_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -502,7 +496,6 @@ class ViewNullComponent0 extends AppView<import1.NullComponent> {
final _rootEl = rootEl;
final import2.HtmlElement parentRenderNode = initViewRoot(_rootEl);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -560,7 +553,6 @@ class ViewInjectsFromArbitraryParent0 extends AppView<import1.InjectsFromArbitra
final _rootEl = rootEl;
final import2.HtmlElement parentRenderNode = initViewRoot(_rootEl);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -636,7 +628,6 @@ class ViewComponentConditionalFeatures0 extends AppView<import1.ComponentConditi
TemplateRef _TemplateRef_1_8 = TemplateRef(_appEl_1, viewFactory_ComponentConditionalFeatures2);
_NgIf_1_9 = NgIf(_appEl_1, _TemplateRef_1_8);
init(const [], null);
return null;
}

@override
Expand Down Expand Up @@ -673,7 +664,6 @@ class _ViewComponentConditionalFeatures1 extends AppView<import1.ComponentCondit
_FeatureA_0_5 = import1.FeatureA();
_compView_0.create(_FeatureA_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -705,7 +695,6 @@ class _ViewComponentConditionalFeatures2 extends AppView<import1.ComponentCondit
_FeatureB_0_5 = import1.FeatureB();
_compView_0.create(_FeatureB_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -775,7 +764,6 @@ class ViewFeatureA0 extends AppView<import1.FeatureA> {
final _text_0 = import2.Text('I am Feature A');
parentRenderNode.append(_text_0);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -835,7 +823,6 @@ class ViewFeatureB0 extends AppView<import1.FeatureB> {
final _text_0 = import2.Text('I am Feature B');
parentRenderNode.append(_text_0);
init(const [], null);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class ViewTestContainerComponent0 extends AppView<import1.TestContainerComponent
_NotDeferredChildComponent_5_5 = import6.NotDeferredChildComponent();
_compView_5.create(_NotDeferredChildComponent_5_5, []);
init(const [], null);
return null;
}

@override
Expand Down Expand Up @@ -143,7 +142,6 @@ class _ViewTestContainerComponent1 extends AppView<import1.TestContainerComponen
_DeferredChild1Component_0_5 = import6.DeferredChild1Component();
_compView_0.create(_DeferredChild1Component_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -174,7 +172,6 @@ class _ViewTestContainerComponent2 extends AppView<import1.TestContainerComponen
TemplateRef _TemplateRef_0_8 = TemplateRef(_appEl_0, viewFactory_TestContainerComponent3);
_cancelDeferredLoad0 = loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_0, _TemplateRef_0_8);
init0(_appEl_0);
return null;
}

@override
Expand Down Expand Up @@ -207,7 +204,6 @@ class _ViewTestContainerComponent3 extends AppView<import1.TestContainerComponen
_DeferredChild2Component_0_5 = import6.DeferredChild2Component();
_compView_0.create(_DeferredChild2Component_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -241,7 +237,6 @@ class _ViewTestContainerComponent4 extends AppView<import1.TestContainerComponen
TemplateRef _TemplateRef_1_8 = TemplateRef(_appEl_1, viewFactory_TestContainerComponent5);
_cancelDeferredLoad1 = loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_1, _TemplateRef_1_8);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -274,7 +269,6 @@ class _ViewTestContainerComponent5 extends AppView<import1.TestContainerComponen
_DeferredChild3Component_0_5 = import6.DeferredChild3Component();
_compView_0.create(_DeferredChild3Component_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -312,7 +306,6 @@ class _ViewTestContainerComponent6 extends AppView<import1.TestContainerComponen
final _text_1 = import4.Text('Hello World');
_compView_0.create(_DeferredChildComponentWithoutNgContent_0_5, []);
init0(_el_0);
return null;
}

@override
Expand Down Expand Up @@ -347,7 +340,6 @@ class _ViewTestContainerComponent7 extends AppView<import1.TestContainerComponen
[_text_1]
]);
init0(_el_0);
return null;
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ViewDeferredChild1Component0 extends AppView<import1.DeferredChild1Compone
final _text_0 = import5.Text('Deferred Child 1');
parentRenderNode.append(_text_0);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -94,7 +93,6 @@ class ViewDeferredChild2Component0 extends AppView<import1.DeferredChild2Compone
final _text_0 = import5.Text('Deferred Child 2');
parentRenderNode.append(_text_0);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -154,7 +152,6 @@ class ViewDeferredChild3Component0 extends AppView<import1.DeferredChild3Compone
final _text_0 = import5.Text('Deferred Child 3');
parentRenderNode.append(_text_0);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -212,7 +209,6 @@ class ViewNotDeferredChildComponent0 extends AppView<import1.NotDeferredChildCom
final _rootEl = rootEl;
final import5.HtmlElement parentRenderNode = initViewRoot(_rootEl);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -274,7 +270,6 @@ class ViewDeferredChildComponentWithoutNgContent0 extends AppView<import1.Deferr
final _text_1 = import5.Text('Child');
_el_0.append(_text_1);
init(const [], null);
return null;
}
}

Expand Down Expand Up @@ -335,7 +330,6 @@ class ViewDeferredChildComponentWithNgContent0 extends AppView<import1.DeferredC
final _el_0 = createDivAndAppend(doc, parentRenderNode);
project(_el_0, 0);
init(const [], null);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class ViewTestFooComponent0 extends AppView<import1.TestFooComponent> {
_TestSubComponent_2_5 = import4.TestSubComponent();
_compView_2.create(_TestSubComponent_2_5, []);
init(const [], null);
return null;
}

@override
Expand Down
Loading

0 comments on commit 7e62eff

Please sign in to comment.