3

Is there any difference (mainly performance) with omiting parentheses when instantiating an object?

var obj1:MyObject = new MyObject();

var obj2:MyObject = new MyObject;

I like the sugar way.

Fabricio
  • 7,705
  • 9
  • 52
  • 87
  • You may be interested in this http://stackoverflow.com/questions/440739/what-do-parentheses-surrounding-a-javascript-object-function-class-declaration-m – Krasimir Sep 08 '13 at 19:32

2 Answers2

4

There is absolutely no difference in the AVM bytecode produced by these two syntaxes.

I used abcdump to look at the ABC code. Below are the results.

AS3

var a1:A = new A;
var a2:A = new A();

ABC

...
5     findpropstrict      private::A
7     constructprop       private::A (0)
10    coerce              private::A
12    setlocal1

13    findpropstrict      private::A
15    constructprop       private::A (0)
18    coerce              private::A
20    setlocal2
...
Ohas
  • 1,887
  • 4
  • 21
  • 29
0

There should be no difference at all (IMHO). From deduction alone, the 1337 SW engineers hired by adobe would probably have both of those compiled to the same instruction since both lines imply the same thing.

mrmoje
  • 3,714
  • 3
  • 20
  • 18