Re: Should send() be able to take an ArrayBufferView?

On Wed, Apr 11, 2012 at 12:04 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> Seems like right now passing a typed array to send() requires a bit of
> extra hoop-jumping to pass the .buffer instead, right?  Is that desirable?
>

It's a bit worse than that, actually: if you want to send only part of a
buffer, you have to create a whole new ArrayBuffer and copy the data over.
 If you just pass "view.buffer", you'll send the *whole* underlying buffer,
not just the slice represented by the view.  Views are supposed to help
prevent those sorts of copies.  All APIs taking typed arrays should accept
ArrayBufferView.

I might argue that we shouldn't have ArrayBuffer entry points at all; just
ArrayBufferView.  It's trivial to create a view on the whole of an
ArrayBuffer, and this is leading towards us having two separate entry
points for every single API that accepts typed arrays.

(This really shouldn't have been a concern; ArrayBuffer and views should
have had a common base class, so they could have been accepted by APIs
interchangeably...)

-- 
Glenn Maynard

Received on Wednesday, 11 April 2012 20:06:38 UTC