-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
Currently the new Buffer(string) constructor calls utf8Length and write, which can be very slow, because Buffer::write calls StringBytes::Write and which calls v8::String::WriteUtf8 with a buffer address and its capacity same as the utf8Length of the string. But v8::String::WriteUtf8 will be very fast if passed with a capacity equals to or larger than three times of the string length (see here).
So I think, why don't we manually make sure the capacity of the buffer is large enough, and pass a larger capacity (for example, three times of the string length) to the WriteUtf8 method, to make it faster?
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.