-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Currently the stream.writev
API has two drawbacks:
- It requires adding properties to the input array (
allBuffers
). - It will always creates an array copy.
- The array entries must be allocated objects.
It would be nice if user space could just create the correctly formatted array without having to perform any allocations, copies and transformations.
In order to not break anything I suggest a new signature writev
maybe called writeMany
?
Which would look something like:
Stream._writeMany = function (chunks, allBuffers, cb) {
}
e.g.
const chunks = [];
for (const { chunk } of data) {
chunks.push(chunk);
}
w._writeMany(chunks, true, cb);
const chunks = [];
for (const { chunk, encoding } of data) {
chunks.push(chunk, encoding);
}
w._writeMany(chunks, false, cb);
Looking at the current Writable
implementation, the writev
scenario will always create two "unnecessary" array copies in order to pass the chunks. Furthermore all the array entries are allocated objects.
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.