Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any advantage in using Vector.<Object> in place of a standard Array?

Because of the inability to create Vectors dynamically, I'm forced to create one with a very primitive type, i.e. Object:

var list:Vector.<Object> = new Vector.<Object>();

I'm assuming that Vector gains its power from being typed as closely as possible, rather than the above, but I may be wrong and there are in-fact still gains when using the above in place of a normal Array or Object:

var list:Array = [];
var list:Object = {};

Does anyone have any insight on this?

like image 965
Marty Avatar asked Oct 24 '25 04:10

Marty


1 Answers

You will not gain any benefits from Vector.< Object > compared to Array or vice versa. Also the underlying data structure will be the same even if you have a tighter coupled Vector such as Vector.< Foo >. The only optimization gains will be if you use value types. The reason for this is that Ecmascript will still be late binding and all reference objects share the same referencing byte structure.

However, in Ecmascript 4 (of which Actionscript is an implementation) the Vector generic datatype adds bounds checking to element access (the non-vector will simply grow the array), so the functionality varies slightly and consequently the number of CPU clock cycles will vary a little bit. This is negligible however.

like image 143
Jack Wester Avatar answered Oct 26 '25 22:10

Jack Wester