Title: [ NOT A BUG ] View.as for() loops Post by: paddy on September 23, 2009, 07:08:00 hi Cliff,
This isn't a bug but after attending Grant Skinners talk at FOTB. There are some small optimisations you could make to the View.as for (var i:Number = 0; i < observers_ref.length; i++) { to var len:int = observers_ref.length i.e using int instead of Number, moving the length calculation out of loop, using ++i instead of ++i could go a little way to helping with large apps... Hope all's well, thanks paddy ;) Title: Re: [ Optimisation ] View.as for() loops Post by: puremvc on September 24, 2009, 07:36:47 length is a property of the observers_ref array which is recalculated by the array whenever items are added or removed (which isn't happening here). Thus our reference to observers_ref.length in the loop condition does no calculation whatsoever so putting it in a separate variable reference before the loop doesn't do anything for us.
And we don't want to use ++i instead of i++ because we don't want to skip the first pass through the loop where i == 0; -=Cliff> Title: Re: [ NOT A BUG ] View.as for() loops Post by: paddy on September 25, 2009, 10:10:12 hi cliff,
That's what I though but ++i doesn't miss first (or last) loop and apprently is slightly more optimal? for (var i:int = 0; i < 10; ++i) { also apprently using int instead of Number in loops has benifical results (perticually for Flash 10): http://gskinner.com/talks/quick/#10 we're prob only talking about small loops here so this will may not have an effect but wanted to mention it after the talk ;) |