Re: Is BlobBuilder needed?

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

> On Mon, Oct 24, 2011 at 19:23, Jonas Sicking <jonas@sicking.cc> wrote:
> >> On the topic of getting rid of BlobBuilder, do you have thoughts on
> losing
> >> the ability to back it by an on-disk file?
> >
> > I'm not sure I understand the problem. A Blob can also be backed by a
> > on-disk file.
> >
> > Could you elaborate?
>
> 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.
>
> Could we add a concat like method to Blob that returns a new "larger" blob?
>

If concat also took an array and/or varargs, then I'd be happy with this and
getting rid of BlobBuilder.


> var bb = new BlobBuilder();
> bb.append(data);
> bb.append(moreData);
> var b = bb.getBlob();
>
> var b = new Blob();
> b = b.concat(data);
> b = b.concat(moreData);
>
> --
> erik
>

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