You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2017/04/19 22:25:53 UTC

[FlaconJX] Vector initialization

Currently as code which looks like this.
var myThingy:Vector.<Thingy> = new Vector.<Thingy>(), it is cross compiled in JS to this:

var myThingy = org.apache.flex.utils.Language.Vector();

Considering that this simple returns an empty array, a compiler optimization could be:

var myThingy = [];

Besides being shorter and more efficient to run, it also eliminates a dependency on org.apache.flex.utils.Language.Vector. This dependency just tripped me up in a const (considering that I’m having issues with the order of file loading when initializing constants in classes).

Thoughts?

Harbs

Re: [FlaconJX] Vector initialization

Posted by Alex Harui <ah...@adobe.com>.

On 4/19/17, 3:25 PM, "Harbs" <ha...@gmail.com> wrote:

>Currently as code which looks like this.
>var myThingy:Vector.<Thingy> = new Vector.<Thingy>(), it is cross
>compiled in JS to this:
>
>var myThingy = org.apache.flex.utils.Language.Vector();
>
>Considering that this simple returns an empty array, a compiler
>optimization could be:
>
>var myThingy = [];
>
>Besides being shorter and more efficient to run, it also eliminates a
>dependency on org.apache.flex.utils.Language.Vector. This dependency just
>tripped me up in a const (considering that I’m having issues with the
>order of file loading when initializing constants in classes).
>
>Thoughts?

I don't know if there are other places where the compiler checks a set of
tokens like that, but the code paths it currently goes down don't.  So, we
could try some special case code, I suppose.  FWIW, I think this is one of
the things the BURM is supposed to be good at.

-Alex