W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

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

From: Glenn Maynard <glenn@zewt.org>
Date: Wed, 11 Apr 2012 15:06:07 -0500
Message-ID: <CABirCh_QtLGA-aabtpf3jsq+BimT9UiZDfMxJNnayfQFcVd=xQ@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: public-webapps <public-webapps@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:51 GMT