Skip to content

Commit 878b2e7

Browse files
TrottBethGriggs
authored andcommitted
benchmark: remove unreachable code from crypto/hash-stream-creation
`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]>
1 parent be63dc5 commit 878b2e7

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

benchmark/crypto/hash-stream-creation.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
5252
while (writes-- > 0) {
5353
const h = crypto.createHash(algo);
5454
h.update(message, encoding);
55-
let res = h.digest(outEnc);
56-
57-
// Include buffer creation costs for older versions
58-
if (outEnc === 'buffer' && typeof res === 'string')
59-
res = Buffer.from(res, 'binary');
55+
h.digest(outEnc);
6056
}
6157

6258
bench.end(gbits);

0 commit comments

Comments
 (0)