-
-
Notifications
You must be signed in to change notification settings - Fork 33.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
I'm really impressed with the new iojs features, an awesome work!
Buffer.compare is a great iojs addition ( memcmp is very fast!), but, unfortunately, the current method implementation doesn't offer a way to compare 2 portions of Buffers: you are forced to slice one or both Buffers to compare desired portions of data.
Now, Buffer.compare accepts 2 buffers as arguments, instead, it could accept 4 args (+1 optional), or something like that:
function ( Buffer b1, Number start1, Buffer b2, Number start2 [, Number length ] ) {}
/*
* For example, comparing 10 bytes:
* - b1 from index 0 to 9
* - b2 from index 16 to 25
*/
Buffer.compare( b1, 0, b2, 16, 10 )
// or, to mantain current signature:
Buffer.compare( b1, b2, 0, 16, 10 )
@trevnorris It would be great if it was planned to add this functionality, it simplify things a lot!!
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.