Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Alex Harui
On 7/26/16, 12:49 PM, "Harbs" wrote: > >On Jul 26, 2016, at 10:39 PM, Alex Harui wrote: > >> >> >> On 7/26/16, 11:39 AM, "Harbs" wrote: >> >>> >>> On Jul 26, 2016, at 8:15 PM, Alex Harui wrote: >>> On 7/26/16, 1:40 AM, "Harbs" wrote: > I noticed a couple of t

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Harbs
On Jul 26, 2016, at 10:39 PM, Alex Harui wrote: > > > On 7/26/16, 11:39 AM, "Harbs" wrote: > >> >> On Jul 26, 2016, at 8:15 PM, Alex Harui wrote: >> >>> >>> >>> On 7/26/16, 1:40 AM, "Harbs" wrote: >>> I noticed a couple of things: 1. There’s lots of String(val) casts in Flex

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Alex Harui
On 7/26/16, 11:39 AM, "Harbs" wrote: > >On Jul 26, 2016, at 8:15 PM, Alex Harui wrote: > >> >> >> On 7/26/16, 1:40 AM, "Harbs" wrote: >> >>> I noticed a couple of things: >>> 1. There’s lots of String(val) casts in FlexJS code. This practice is >>> considered “bad” practice in Javascript w

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Josh Tynjala
How terrible it is depends on context, I guess. Starling and Feathers try to maintain 60fps on slightly older mobile hardware. If the GC causes dropped frames, it's terrible. Switching away from push() (and splice(), which has two temporary Arrays) made a noticeable difference. It's worth mentioni

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Harbs
On Jul 26, 2016, at 8:15 PM, Alex Harui wrote: > > > On 7/26/16, 1:40 AM, "Harbs" wrote: > >> I noticed a couple of things: >> 1. There’s lots of String(val) casts in FlexJS code. This practice is >> considered “bad” practice in Javascript where implicit conversion is >> generally quicker. S

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Harbs
Interesting. Good to know. Here’s what I got: function timeJoin(){ var start = new Date(); var i=-1; var len = 1000; var arr = []; while(++i wrote: > Yeah, push() is terribly bad for performance because of the GC overhead > from the ...rest Array. In S

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Josh Tynjala
Yeah, push() is terribly bad for performance because of the GC overhead from the ...rest Array. In Starling and Feathers, we always try to avoid push() whenever possible. We usually use bracket syntax instead: array[array.length] = newValue; In loops, it's possible to use a local integer counter

Re: [FlexJS] Javascript efficient code patterns

2016-07-26 Thread Alex Harui
On 7/26/16, 1:40 AM, "Harbs" wrote: >I noticed a couple of things: >1. There’s lots of String(val) casts in FlexJS code. This practice is >considered “bad” practice in Javascript where implicit conversion is >generally quicker. So in a case where a number can be converted >implicitly, the cast

[FlexJS] Javascript efficient code patterns

2016-07-26 Thread Harbs
I noticed a couple of things: 1. There’s lots of String(val) casts in FlexJS code. This practice is considered “bad” practice in Javascript where implicit conversion is generally quicker. So in a case where a number can be converted implicitly, the cast should be completely skipped and even when