flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: [FlexJS] Javascript efficient code patterns
Date Tue, 26 Jul 2016 19:53:07 GMT

On 7/26/16, 12:49 PM, "Harbs" <harbs.lists@gmail.com> wrote:

>On Jul 26, 2016, at 10:39 PM, Alex Harui <aharui@adobe.com> wrote:
>> On 7/26/16, 11:39 AM, "Harbs" <harbs.lists@gmail.com> wrote:
>>> On Jul 26, 2016, at 8:15 PM, Alex Harui <aharui@adobe.com> wrote:
>>>> On 7/26/16, 1:40 AM, "Harbs" <harbs.lists@gmail.com> wrote:
>>>>> I noticed a couple of things:
>>>>> 1. There’s lots of String(val) casts in FlexJS code. This practice
>>>>> considered “bad” practice in Javascript where implicit conversion
>>>>> generally quicker. So in a case where a number can be converted
>>>>> implicitly, the cast should be completely skipped and even when a
>>>>> number
>>>>> needs to be converted to a string, “” + val is more efficient than
>>>>> String(val). This is especially true in FlexJS where (I believe) such
>>>>> code will result in org.apache.flex.Language.as(val,”String”).
>>>> I'm not seeing this.  What source code is generating String(val)
>>>> Regarding optimization, do we know if GCC will do this ("" + val)
>>>> optimization for us?
>>>> In general, there is a big TODO around type conversions.
>>> Good question. I just checked and there’s both String() and toString()
>>> calls in the optimized code. One example:
>>> return RA+String(a)+bc+String(this.alpha)}; It’s coming from one of the
>>> Graphic classes.
>> It would save me time to not have to search through the code for test
>> cases if you have them handy.
>I already replaced this one. Are you saying you are thinking of doing
>this replacement in the compiler? I’m not sure it’s really necessary.
>Implicit string conversions should be fine in Flash as well.

I guess I misunderstood.  I thought you were saying the generated code had
un-wanted String() calls.  If it is in the source itself, then that's fine
if you are sure the implicit conversion will "do the right thing".  I've
been burned enough that I probably am the person that adds these
unnecessary calls.


View raw message