From a8cbe0e6d2a989ad59e2bbffea5836b05e37486f Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Mon, 11 Mar 2019 22:53:58 +0800 Subject: [PATCH] benchmark: replace deprecated and eliminate var in buffer-from.js PR-URL: https://github.com/nodejs/node/pull/26585 Reviewed-By: Richard Lau Reviewed-By: Daniel Bevenius Reviewed-By: Anna Henningsen --- benchmark/buffers/buffer-from.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/benchmark/buffers/buffer-from.js b/benchmark/buffers/buffer-from.js index 6f2358bcf296ab..23ffec7680f570 100644 --- a/benchmark/buffers/buffer-from.js +++ b/benchmark/buffers/buffer-from.js @@ -26,19 +26,17 @@ function main({ len, n, source }) { const uint8array = new Uint8Array(len); const obj = { length: null }; // Results in a new, empty Buffer - var i; - switch (source) { case 'array': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(array); } bench.end(n); break; case 'arraybuffer': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(arrayBuf); } bench.end(n); @@ -47,54 +45,54 @@ function main({ len, n, source }) { const offset = ~~(len / 4); const length = ~~(len / 2); bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(arrayBuf, offset, length); } bench.end(n); break; case 'buffer': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(buffer); } bench.end(n); break; case 'uint8array': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(uint8array); } bench.end(n); break; case 'string': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(str); } bench.end(n); break; case 'string-utf8': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(str, 'utf8'); } bench.end(n); break; case 'string-base64': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(str, 'base64'); } bench.end(n); break; case 'object': bench.start(); - for (i = 0; i < n * 1024; i++) { + for (let i = 0; i < n * 1024; i++) { Buffer.from(obj); } bench.end(n); break; default: - assert.fail(null, null, 'Should not get here'); + assert.fail('Should not get here'); } }