Skip to content

Commit

Permalink
benchmark: remove unreachable code from crypto/hash-stream-creation
Browse files Browse the repository at this point in the history
`hash.digest('buffer')` has returned a Buffer and not a string since at
least Node.js 0.10.6. The benchmark, as it is written, will not work on
any version of Node.js prior to 16.x (due to `Object.hasOwn()`) and
certainly won't run on versions earlier than 0.10.6 due to const/let and
probably other things. Remove impossible-to-reach code intended to
accommodate Node.js earlier than 0.10.6.

PR-URL: #41535
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Trott authored Jan 17, 2022
1 parent 986cf3b commit a7215c8
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions benchmark/crypto/hash-stream-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
while (writes-- > 0) {
const h = crypto.createHash(algo);
h.update(message, encoding);
let res = h.digest(outEnc);

// Include buffer creation costs for older versions
if (outEnc === 'buffer' && typeof res === 'string')
res = Buffer.from(res, 'binary');
h.digest(outEnc);
}

bench.end(gbits);
Expand Down

0 comments on commit a7215c8

Please sign in to comment.