| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Perhaps the order should be tweaked a bit here and have length and thisOffset swapped to match more closely with buffer.copy() which also deals with two buffers?
I also think offset might be better renamed to something like otherOffset.
Sorry, something went wrong.
There was a problem hiding this comment.
Possibly follow suit of copy() since it follows similar parameters.
Sorry, something went wrong.
|
@trevnorris @mscdex ... updated! PTAL The signature has been changed to: buf.compare(other[, otherStart[, thisStart[, otherEnd[, thisEnd]]]]) |
Sorry, something went wrong.
|
Couldn't we just have one end value, thisEnd, or just keep length instead of the end parameters? If not, I would prefer seeing buf.compare(other[, otherStart[, otherEnd[, thisStart[, thisEnd]]]]). |
Sorry, something went wrong.
|
Personally I'd prefer to keep length. I changed it to this to align with the signature for buf.copy() |
Sorry, something went wrong.
|
That said, having it as just length limits you to always comparing equal length ranges which is not always desirable. |
Sorry, something went wrong.
|
@mscdex ... updated ... I swapped the order of the arguments but kept separate otherEnd and thisEnd. The signature has been changed to: buf.compare(other[, otherStart[, otherEnd[, thisStart[, thisEnd]]]]) |
Sorry, something went wrong.
|
Currently, thisEnd defaults to this.byteLength, however, we could make it so that if thisEnd is not specified, it defaults to Math.min(this.byteLength, thisStart + (otherEnd - otherStart))) |
Sorry, something went wrong.
|
doing so causes surprising behavior tho: const a = Buffer.from([1,2,3,4,5,6,7,8,9]);
const b = Buffer.from([5,6,7,8,9,1,2,3,4]);
console.log(a.compare(b, 5, 9));
// Prints 0 |
Sorry, something went wrong.
|
I don't think it's that much of a surprising behavior considering that the default for sourceStart for .copy() is also 0. |
Sorry, something went wrong.
|
the surprising behavior is that the subset of b is not compared to the full content of a. If I did Buffer.compare(a, b.slice(5, 9)) I would get a different result. |
Sorry, something went wrong.
There was a problem hiding this comment.
Can we use source/target to mirror copy()? Think it will have less mental impact.
Sorry, something went wrong.
There was a problem hiding this comment.
we could but source/target make a lot more sense in copy than they do in compare.
Sorry, something went wrong.
|
@jasnell One documentation comment, but implementation LGTM. |
Sorry, something went wrong.
Sorry, something went wrong.
|
@mscdex ... any further thoughts on this one? |
Sorry, something went wrong.
There was a problem hiding this comment.
What about moving the bench.start()/bench.end() to be closer to the actual loop in the respective functions?
Sorry, something went wrong.
|
@jasnell Just a few more comments/questions. |
Sorry, something went wrong.
|
@trevnorris @mscdex ... updated and rebased. PTAL! |
Sorry, something went wrong.
There was a problem hiding this comment.
These should have been handled in JS. Instead can they all be turned into CHECKs? e.g.
CHECK(target_start >= target_end && source_start >= source_end);
CHECK_GE(source_start >= source_end);
CHECK_GE(target_start >= target_end);Since if one of these is hit then it would indicate a bug on the JS side.
Sorry, something went wrong.
|
One comment, but LGTM otherwise. |
Sorry, something went wrong.
Adds additional `targetStart`, `targetEnd`, `sourceStart, and `sourceEnd` arguments to `Buffer.prototype.compare` to allow comparison of sub-ranges of two Buffers without requiring Buffer.prototype.slice() Fixes: nodejs#521
|
@trevnorris ... updated! squashed the commits. New CI: https://ci.nodejs.org/job/node-test-pull-request/2227/ |
Sorry, something went wrong.
|
If CI is happy LGTM |
Sorry, something went wrong.
|
Failures in CI are unrelated. |
Sorry, something went wrong.
Buffer: * Buffer.prototype.compare can now compare sub-ranges of two Buffers (James M Snell) #5880 deps: * update to http-parser 2.7.0 (Fedor Indutny) #6279 * update ESLint to 2.7.0 (silverwind) #6132 net: * adds support for passing DNS lookup hints to createConnection() (Colin Ihrig) #6000 node: * Make the builtin libraries available for the --eval and --print CLI options (Anna Henningsen) #6207 npm: * upgrade npm to 3.8.6 (Kat Marchán) #6153 repl: * Pressing enter in the repl will repeat the last command by default if no input has been received. This behaviour was in node previously and was not removed intentionally. (Rich Trott) #6090 src: * add SIGINFO to supported signals (James Reggio) #6093 streams: * Fix a regression that caused by net streams requesting multiple chunks synchronously when combined with cork/uncork (Matteo Collina) #6164 zlib: * The flushing flag is now configurable allowing for decompression of partial data (Anna Henningsen) #6069
Buffer: * Buffer.prototype.compare can now compare sub-ranges of two Buffers (James M Snell) #5880 deps: * update to http-parser 2.7.0 (Fedor Indutny) #6279 * update ESLint to 2.7.0 (silverwind) #6132 net: * adds support for passing DNS lookup hints to createConnection() (Colin Ihrig) #6000 node: * Make the builtin libraries available for the --eval and --print CLI options (Anna Henningsen) #6207 npm: * upgrade npm to 3.8.6 (Kat Marchán) #6153 repl: * Pressing enter in the repl will repeat the last command by default if no input has been received. This behavior was in node previously and was not removed intentionally. (Rich Trott) #6090 src: * add SIGINFO to supported signals (James Reggio) #6093 streams: * Fix a regression that caused by net streams requesting multiple chunks synchronously when combined with cork/uncork (Matteo Collina) #6164 zlib: * The flushing flag is now configurable allowing for decompression of partial data (Anna Henningsen) #6069
Buffer: * Buffer.prototype.compare can now compare sub-ranges of two Buffers (James M Snell) #5880 deps: * update to http-parser 2.7.0 (Fedor Indutny) #6279 * update ESLint to 2.7.0 (silverwind) #6132 net: * adds support for passing DNS lookup hints to createConnection() (Colin Ihrig) #6000 node: * Make the builtin libraries available for the --eval and --print CLI options (Anna Henningsen) #6207 npm: * upgrade npm to 3.8.6 (Kat Marchán) #6153 repl: * Pressing enter in the repl will repeat the last command by default if no input has been received. This behaviour was in node previously and was not removed intentionally. (Rich Trott) #6090 src: * add SIGINFO to supported signals (James Reggio) #6093 streams: * Fix a regression that caused by net streams requesting multiple chunks synchronously when combined with cork/uncork (Matteo Collina) #6164 zlib: * The flushing flag is now configurable allowing for decompression of partial data (Anna Henningsen) #6069 PR-URL: #6322
Buffer: * Buffer.prototype.compare can now compare sub-ranges of two Buffers (James M Snell) #5880 deps: * update to http-parser 2.7.0 (Fedor Indutny) #6279 * update ESLint to 2.7.0 (silverwind) #6132 net: * adds support for passing DNS lookup hints to createConnection() (Colin Ihrig) #6000 node: * Make the builtin libraries available for the --eval and --print CLI options (Anna Henningsen) #6207 npm: * upgrade npm to 3.8.6 (Kat Marchán) #6153 repl: * Pressing enter in the repl will repeat the last command by default if no input has been received. This behaviour was in node previously and was not removed intentionally. (Rich Trott) #6090 src: * add SIGINFO to supported signals (James Reggio) #6093 streams: * Fix a regression that caused by net streams requesting multiple chunks synchronously when combined with cork/uncork (Matteo Collina) #6164 zlib: * The flushing flag is now configurable allowing for decompression of partial data (Anna Henningsen) #6069 PR-URL: #6322
Buffer: * Buffer.prototype.compare can now compare sub-ranges of two Buffers (James M Snell) nodejs#5880 deps: * update to http-parser 2.7.0 (Fedor Indutny) nodejs#6279 * update ESLint to 2.7.0 (silverwind) nodejs#6132 net: * adds support for passing DNS lookup hints to createConnection() (Colin Ihrig) nodejs#6000 node: * Make the builtin libraries available for the --eval and --print CLI options (Anna Henningsen) nodejs#6207 npm: * upgrade npm to 3.8.6 (Kat Marchán) nodejs#6153 repl: * Pressing enter in the repl will repeat the last command by default if no input has been received. This behaviour was in node previously and was not removed intentionally. (Rich Trott) nodejs#6090 src: * add SIGINFO to supported signals (James Reggio) nodejs#6093 streams: * Fix a regression that caused by net streams requesting multiple chunks synchronously when combined with cork/uncork (Matteo Collina) nodejs#6164 zlib: * The flushing flag is now configurable allowing for decompression of partial data (Anna Henningsen) nodejs#6069 PR-URL: nodejs#6322
Buffer: * Buffer.prototype.compare can now compare sub-ranges of two Buffers (James M Snell) #5880 deps: * update to http-parser 2.7.0 (Fedor Indutny) #6279 * update ESLint to 2.7.0 (silverwind) #6132 net: * adds support for passing DNS lookup hints to createConnection() (Colin Ihrig) #6000 node: * Make the builtin libraries available for the --eval and --print CLI options (Anna Henningsen) #6207 npm: * upgrade npm to 3.8.6 (Kat Marchán) #6153 repl: * Pressing enter in the repl will repeat the last command by default if no input has been received. This behaviour was in node previously and was not removed intentionally. (Rich Trott) #6090 src: * add SIGINFO to supported signals (James Reggio) #6093 streams: * Fix a regression that caused by net streams requesting multiple chunks synchronously when combined with cork/uncork (Matteo Collina) #6164 zlib: * The flushing flag is now configurable allowing for decompression of partial data (Anna Henningsen) #6069 PR-URL: #6322
| Back | FazBrowse Home | New Git URL |
Pull Request check-list
this change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
Affected core subsystem(s)
buffer
Description of change
Adds additional offset, length and thisOffset arguments
to Buffer.prototype.compare to allow comparison of sub-ranges
of two Buffers without requiring Buffer.prototype.slice()
Fixes: #521
/cc @trevnorris @rootslab @jorangreef