Sections 9.1.1 and 9.2.1 of the draft WebCodecs spec say:
- Assign a copy of init.data to chunk.data.
I suggest the words a copy of be removed from the spec. It seems like leaving those words in requires unnecessary copying of compressed bitstream data.
Leaving these words out would allow a client of these constructors to make the decision about copying that data. It's possible for a client to pass a .subarray() of some ArrayBuffer. If that ArrayBuffer is volatile for some reason, it should be up to the client to copy the data.
Of course, if a decoder implementation requires the compressed bitstream data to be copied, the implementation can do so. But promising to do so adds a required copying step.
How about this wording?
- Assign init.data to chunk.data. The client must not allow init.data to change after using this ctor.