Re: [XHR2] ArrayBuffer integration

On Sep 27, 2010, at 6:22 PM, Michael Nordman wrote:

> A couple of us have been looking at webkit's XHR impl and realized that to support performant access to the response via responseArrayBuffer and responseText would cause us to keep two copies of the data around, a raw data buffer and the second decoded text buffer. Considering the overwhelming number of responseText only use cases, it would be nice to not incur extra costs to support a new binary accessor which would be rarely used compared to the text accessor. So some way of making these mutually exclusive in the API.
> 
> Should we have an asArrayBuffer attribute (or similar) to tell XHR up front how the caller wishes to access the response?
> 
> Or maybe specify the accessors such that when you use responseText you can not later access responseArrayBuffer and vice versa?
> 
> Are there any use cases where you'd need it both ways?

I'd hate the idea of another flag in XHR. Why not just keep the raw bits and then convert when responseText is called? The only disadvantage of this is when the author makes multiple calls to responseText and I would not think that is a very common use case.

-----
~Chris
cmarrin@apple.com

Received on Tuesday, 28 September 2010 14:33:53 UTC