Re: [whatwg] BinaryEncoding for Typed Arrays using window.btoa and window.atob

That's a very good point, TJ. Thanks.

Chang

On Mon, Aug 5, 2013 at 4:30 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Mon, Aug 5, 2013 at 12:41 PM, Simon Pieters <simonp@opera.com> wrote:
>>> var newarr = new Int32Array();
>>> window.atob(encodedData, newarr); //decode base-64 string back to integer
>>> array
>>> //newarr[0] should be 1, newarr[1] should be 2 and newarr[2] should be 3.
>>
>> Is there a reason to support an arbitrary typed array for atob rather than
>> returning a new typed array?
>>
>> e.g.
>>
>> var newarr = atob(encodedData, {typedarray:true});
>>
>> (I'm not sure which view is most appropriate to return.)
>
> Decoding into a given typed array means you can reuse the same
> (potentially large) buffer multiple times, rather than creating new
> ones with every call.  Avoiding the GC churn can be significant.  It
> also means you can decode several strings into the same typed array at
> different offsets.
>
> ~TJ

Received on Monday, 5 August 2013 20:40:52 UTC