I’m not sure. One thought I had (which might help get better minified code in general) is to use the getter functions rather than the getters themselves. i.e. in this case output "return get__computedFormat()" instead of "return computedFormat”.
> On Feb 4, 2019, at 6:52 PM, Alex Harui <[email protected]> wrote: > > That is the correct analysis. What do you propose the compiler do > differently? > > -Alex > > On 2/4/19, 1:57 AM, "Harbs" <[email protected]> wrote: > > TLF has the following code in SpanElement: > > > /** @private */ > override public function createContentElement():void > { > if (_blockElement && _blockElement.textBlock) > return; > > calculateComputedFormat(); // BEFORE creating the > element > _blockElement = new TextElement(_text,null); > > super.createContentElement(); > } > > Which gets compiled to this: > > /** @asprivate > * @export > * @override > */ > > org.apache.royale.textLayout.elements.SpanElement.prototype.createContentElement > = function() { > if (this._blockElement && this._blockElement.textBlock) > return; > this.calculateComputedFormat(); > this._blockElement = new com.printui.text.engine.TextElement(this._text, > null); > > > > org.apache.royale.textLayout.elements.SpanElement.superClass_.createContentElement.apply(this); > }; > > Minified, that function looks like this: > hK.prototype.sf = function() { > this.Xa && this.Xa.textBlock || (this.Xa = new iK(this._text,null), > hK.o.sf.apply(this)) > } > > Notice that the function call of calculateComputedFormat(); is missing in > the minified code. > > The reason for this is because the function is deemed to not have side > effects by the Closure compiler. > > That function (in FlowElement) looks like this: > public function get computedFormat():ITextLayoutFormat > { > if (_computedFormat == null) > _computedFormat = doComputeTextLayoutFormat(); > return _computedFormat; > } > > public function calculateComputedFormat():ITextLayoutFormat > { > // use the class-sppecific getter > return computedFormat; > } > Apparently, the Closure Compiler assumes that getters do not have side > effects. > > I can work around this problem in TLF, but it seems to me that this is a > problem which should be fixed in the compiler. > > Thoughts? > Harbs > > >
