Handling of missing 'len' parameter in OutputStream.writeFrom #292
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
type-enhancement
A request for a change that isn't a bug
This issue was originally filed by [email protected]
The new OutputStream interface contains the following code:
/**
* Writes [len] bytes from buffer [buffer] starting at offset
* [offset] to the output stream. If [offset] is not specified the
* default is 0. If [len] is not specified the default is the length
* of the buffer passed. The system will copy the data to be written
* so the caller can safely change [buffer] afterwards. Returns true
* if the data could be written to the underlying communication
* channel immediately. Otherwise the data is buffered by the output
* stream and will be sent as soon as possible.
*/
bool writeFrom(List<int> buffer, [int offset, int len]);
It seems like it would be more useful for the value of len (if not supplied) to be equal to (buffer.length - offset) rather than buffer.length. Thus would allow 'writeFrom(buf, offset)' to mean 'write the portion of the buffer from offset forward', whereas in the current scheme it will always result in an IndexOutOfRangeException when offset > 0.
The text was updated successfully, but these errors were encountered: