gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-commit] gnash ChangeLog server/array.cpp server/array.h...


From: Sandro Santilli
Subject: Re: [Gnash-commit] gnash ChangeLog server/array.cpp server/array.h...
Date: Wed, 19 Mar 2008 13:02:05 +0100

On Wed, Mar 19, 2008 at 11:40:18AM +0000, Sandro Santilli wrote:
> CVSROOT:      /sources/gnash
> Module name:  gnash
> Changes by:   Sandro Santilli <strk>  08/03/19 11:40:16
> 
> Modified files:
>       .              : ChangeLog 
>       server         : array.cpp array.h 
>       testsuite/actionscript.all: array.as 
> 
> Log message:
>               * server/array.{cpp,h}: use boost's mapped_vector for a sparse
>                 array implementation. Saves space at some cpu cycles till all
>                 gaps are filled (which happens by most modifiers, as an 
> expected
>                 behaviour :/).

Basically this commit avoids taking up a lot of memory in this case:

        a = new Array();
        a[1000000] = 1;

Former implementation would allocate slots for 1000000 items, this one allocates
only one, and can still distinguish between *real* values and *holes*.

The distinction between existing and fake values from ActionScript is that
real values return true on hasOwnProperty, while others return false.
For the example above:

        a.hasOwnProperty(1000000);
        !a.hasOwnProperty(1);

Also, when enumerating an array, only the real indexes are enumerated:

        for (var i in a) { /* enters the loop one time only*/ }

It is still worth coming back on this for better correctness, in that
property flags would likely change the enumeration behaviour (hide
from enumeration) and deletions are not properly hanldled either. 
This is because we're still using a separate container, not the hash
used for normal objects.

--strk;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]