[Public WebGL] Typed Array setter for partial arrays (and typed array performance)

Brian Cornell [email protected]
Mon May 2 13:37:36 PDT 2011

So if you are using just an ArrayBuffer with a DataView and want to copy a
subset of it (so the rest can be garbage collected, just keep a small part
of it), is the recommendation to do the following?

var buffer = DataView.buffer;
var tmpToCopy = new Uint8Array(buffer, start, end);  // Even though the data
is not all Uint8s
var tmpCopied = new Uint8Array(tmpToCopy);
var subBuffer = tmpToCopy.buffer;
var subView = new DataView(subBuffer);

That seems convoluted and unobvious, especially the fact that I have to
treat my many-typed data as all Uint8s just because only TypedArrays have
ways to copy data.


On Thu, Apr 28, 2011 at 5:06 PM, Kenneth Russell <[email protected]> wrote:

> On Wed, Apr 27, 2011 at 10:48 AM, Chris Marrin <[email protected]> wrote:
> >
> > On Apr 21, 2011, at 4:12 PM, Kenneth Russell wrote:
> >
> >>
> >> ...
> >> As part of the planned Typed Array API changes to support efficient
> >> communication with web workers, the plan is to add convenience methods
> >> to copy ArrayBuffers and possibly sub-portions of them. I think we
> >> should invest our time in moving those changes forward.
> >
> > Why is it necessary to have functions to copy ArrayBuffers. Isn't the
> copy constructor in the TypedArrays sufficient?
> That's a fair point. During one of the face-to-face meetings with
> Mozilla it seemed that if we used transfer-of-ownership for
> ArrayBuffers sent via postMessage, then we had to make it easy to copy
> them. You're right, though, that the slice() operation can be easily
> implemented in pure JavaScript, with the only cost the creation of two
> temporary Uint8Arrays.
> Should we just get rid of it and provide non-normative text showing
> how it could be implemented?
> -Ken
> -----------------------------------------------------------
> You are currently subscribed to [email protected]
> To unsubscribe, send an email to [email protected] with
> the following command in the body of your email:
> unsubscribe public_webgl
> -----------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110502/67877156/attachment.html>

More information about the public_webgl mailing list