tc39 / proposal-immutable-arraybuffer

A TC39 proposal for immutable ArrayBuffers
http://tc39.es/proposal-immutable-arraybuffer/
MIT License
12 stars 1 forks source link

Also good for web APIs #2

Closed bakkot closed 3 weeks ago

bakkot commented 4 weeks ago

Just pointing out another advantage: a number of web APIs take buffers, and because they need to worry about destructive writes, they are forced to copy the contents of the underlying buffer. Such APIs could be updated to check the immutable bit and skip the copy if so.

The same for userland APIs which take ArrayBuffers as well, of course, though I think they often simply tell consumers it's their responsibility not to mutate the buffer while the API is working rather than pessimistically copying.

(Some commentary on a different possible fix here.)

gibson042 commented 3 weeks ago

@bakkot Does #3 adequately cover this motivation/benefit?