Re: Is BlobBuilder needed?

On Mon, Oct 24, 2011 at 10:49 PM, Erik Arvidsson <arv@chromium.org> wrote:

> I think the point is that with the old one you could generate lots of
> data, add that to the blob, generate a lot more data and add that to
> the blob. After every add it might be safe to gc that data. With this
> proposal all that data needs to be in memory at the point of
> construction.
>

It doesn't.  Each individual "low-level" Blob can be swapped to disk, and
stay there; you don't need to read it into memory to construct new Blobs
containing it.

Repeating my earlier example:

var b = new Blob();
ongotdataevent = function(blobToAppend) { b = new Blob(b, blobToAppend); }

You don't need to have any of the previous Blobs in memory when you create
each new compound Blob; you only need to know where to get them later, and
their size.



> Could we add a concat like method to Blob that returns a new "larger" blob?
>
> var bb = new BlobBuilder();
> bb.append(data);
> bb.append(moreData);
> var b = bb.getBlob();
>

This is the same as the above: new Blob(data, moreData).  There's no need
for a special method for this.

-- 
Glenn Maynard

Received on Tuesday, 25 October 2011 02:56:56 UTC