AlternativaPlatform/Alternativa3D

Performance optimizations using object literals

Opened this issue · 3 comments

Object literals are faster than the new operator

Strings, Numbers (including int and uint), and Boolean objects are usually instantiated using literal notation (var str:String = “text”). Objects and Arrays are often instantiated using the “new” operator – this is seldom necessary (only in the case of a fixed-length Array), and is slower.

var o:Object = {}; is faster than var o:Object = new Object();

and

var a:Array = []; is faster than var a:Array = new Array();

makc commented

you forgot to attach the patch :)

+1 :)

I tried to commit the changes but I'm still learning how to use this properly and I'm not sure if everything worked as expected.