From 4215431d8202e3a16c63259443f7b3eb1e810812 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 14 Jan 2022 16:49:33 -0800 Subject: [PATCH] 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. --- benchmark/crypto/hash-stream-creation.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/benchmark/crypto/hash-stream-creation.js b/benchmark/crypto/hash-stream-creation.js index c21eb6eaaaed99..e480c7b6edcc41 100644 --- a/benchmark/crypto/hash-stream-creation.js +++ b/benchmark/crypto/hash-stream-creation.js @@ -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);