Vectors offer much better performance as well. Check this example from
the Adobe docs on performance optimizing Flash 10 apps:

Flash Player 10 introduced the Vector class, which allows faster read
and write access than the Array class.
A simple benchmark shows the benefits of the Vector class over the
Array class. The following code shows a benchmark for the Array class:
var coordinates:Array = new Array();
var started:Number = getTimer();
for (var i:int = 0; i< 300000; i++) {
  coordinates[i] = Math.random()*1024;
}
trace(getTimer() - started); // output: 107

The following code shows a benchmark for the Vector class:
var coordinates:Vector.<Number> = new Vector.<Number>();
var started:Number = getTimer();
for (var i:int = 0; i< 300000; i++)  {
 coordinates[i] = Math.random()*1024;
}
trace(getTimer() - started); // output: 72

On Tue, Jun 1, 2010 at 2:56 PM, P T Withington <[email protected]> wrote:
> Indeed.  We jumped the gun on classes, and see where that has gotten us!  :P  
> (Actually, I think adopting classes, and optional and rest args and types, 
> was the right thing to do, it's just too bad that they did not make it into 
> ES5.  But we did learn a lesson on how easy it is for a standards committee 
> to change their mind.)
>
> On 2010-06-01, at 08:24, André Bargull wrote:
>
>> There is an old ES4 proposal for typed vectors, but it wasn't updated since 
>> almost three years. Also see LPP-6709.
>>
>>> On 2010-06-01, at 00:15, Henry Minsky wrote:
>>>
>>> >/  In the new flash text layout package, some of the API's text engine 
>>> >classes
>>> />/  require Vector arguments. Our compiler
>>> />/  doesn't understand this syntax, I assume.  I think I can deal with 
>>> this in
>>> />/  the kernel using  #passthrough blocks where I need
>>> />/  to construct or access Vectors. Is this likely to become standard
>>> />/  javascript? Should we be supporting the
>>> />/  syntax in our script compiler? Seems a little bit of a stretch...
>>> /
>>> The only ECMA work on typed arrays that I am aware of is focusing on 
>>> byte-arrays:
>>>
>>>   http://wiki.ecmascript.org/doku.php?id=strawman:typed_arrays
>>>
>>> not on arrays of arbitrary type.  So, I don't think we should be trying to 
>>> invent an extension here if we can avoid it.  (I think that most runtimes 
>>> create typed arrays for you, under the covers, as an optimization.  We know 
>>> for instance, that even as2 watched the keys of array and used a different 
>>> implementation if all the keys were integers in a small range [we know this 
>>> because there were bugs in their implementation at first].)
>>>
>>
>
>
>

Reply via email to