Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance optimizations using object literals #31

Open
wilsonsilva opened this issue Oct 9, 2012 · 3 comments
Open

Performance optimizations using object literals #31

wilsonsilva opened this issue Oct 9, 2012 · 3 comments

Comments

@wilsonsilva
Copy link
Contributor

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
Copy link
Contributor

makc commented Oct 9, 2012

you forgot to attach the patch :)

@Yaski
Copy link
Contributor

Yaski commented Oct 9, 2012

+1 :)

@wilsonsilva
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants