From f3ef8946d01c909916e127bdd21e2ee60619d3d7 Mon Sep 17 00:00:00 2001 From: Daniele Belardi Date: Fri, 14 Feb 2020 13:13:58 +0100 Subject: [PATCH] benchmark: use let instead of var in timers PR-URL: https://github.com/nodejs/node/pull/31794 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- benchmark/timers/immediate.js | 10 +++++----- benchmark/timers/timers-breadth-args.js | 2 +- benchmark/timers/timers-breadth.js | 2 +- benchmark/timers/timers-cancel-pooled.js | 4 ++-- benchmark/timers/timers-cancel-unpooled.js | 5 ++--- benchmark/timers/timers-depth.js | 2 +- benchmark/timers/timers-insert-unpooled.js | 5 ++--- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/benchmark/timers/immediate.js b/benchmark/timers/immediate.js index d12106a0e030fc..3bd4c097dce5a0 100644 --- a/benchmark/timers/immediate.js +++ b/benchmark/timers/immediate.js @@ -31,7 +31,7 @@ function main({ n, type }) { // setImmediate tail recursion, 0 arguments function depth(N) { - var n = 0; + let n = 0; bench.start(); setImmediate(cb); function cb() { @@ -45,7 +45,7 @@ function depth(N) { // setImmediate tail recursion, 1 argument function depth1(N) { - var n = 0; + let n = 0; bench.start(); setImmediate(cb, 1); function cb(a1) { @@ -59,7 +59,7 @@ function depth1(N) { // Concurrent setImmediate, 0 arguments function breadth(N) { - var n = 0; + let n = 0; bench.start(); function cb() { n++; @@ -73,7 +73,7 @@ function breadth(N) { // Concurrent setImmediate, 1 argument function breadth1(N) { - var n = 0; + let n = 0; bench.start(); function cb(a1) { n++; @@ -88,7 +88,7 @@ function breadth1(N) { // Concurrent setImmediate, 4 arguments function breadth4(N) { N /= 2; - var n = 0; + let n = 0; bench.start(); function cb(a1, a2, a3, a4) { n++; diff --git a/benchmark/timers/timers-breadth-args.js b/benchmark/timers/timers-breadth-args.js index 63a301dc9bc7dc..bf1727ab865b6d 100644 --- a/benchmark/timers/timers-breadth-args.js +++ b/benchmark/timers/timers-breadth-args.js @@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, { }); function main({ n }) { - var j = 0; + let j = 0; function cb1(arg1) { j++; if (j === n) diff --git a/benchmark/timers/timers-breadth.js b/benchmark/timers/timers-breadth.js index 78bd5a97ae84b8..7af5d380018898 100644 --- a/benchmark/timers/timers-breadth.js +++ b/benchmark/timers/timers-breadth.js @@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, { }); function main({ n }) { - var j = 0; + let j = 0; bench.start(); function cb() { j++; diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js index 5045983210263e..30dbd7bc007d7a 100644 --- a/benchmark/timers/timers-cancel-pooled.js +++ b/benchmark/timers/timers-cancel-pooled.js @@ -8,11 +8,11 @@ const bench = common.createBenchmark(main, { function main({ n }) { - var timer = setTimeout(() => {}, 1); + let timer = setTimeout(() => {}, 1); for (let i = 0; i < n; i++) { setTimeout(cb, 1); } - var next = timer._idlePrev; + let next = timer._idlePrev; clearTimeout(timer); bench.start(); diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js index df203ee4810b1d..70f8fd96c9cbf1 100644 --- a/benchmark/timers/timers-cancel-unpooled.js +++ b/benchmark/timers/timers-cancel-unpooled.js @@ -14,14 +14,13 @@ function main({ n, direction }) { timersList.push(setTimeout(cb, i + 1)); } - var j; bench.start(); if (direction === 'start') { - for (j = 0; j < n; j++) { + for (let j = 0; j < n; j++) { clearTimeout(timersList[j]); } } else { - for (j = n - 1; j >= 0; j--) { + for (let j = n - 1; j >= 0; j--) { clearTimeout(timersList[j]); } } diff --git a/benchmark/timers/timers-depth.js b/benchmark/timers/timers-depth.js index bfc6dd02cf5c65..766733ba1862a9 100644 --- a/benchmark/timers/timers-depth.js +++ b/benchmark/timers/timers-depth.js @@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, { }); function main({ n }) { - var i = 0; + let i = 0; bench.start(); setTimeout(cb, 1); function cb() { diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js index 11d25d5fe79670..5ee255b5e15fd2 100644 --- a/benchmark/timers/timers-insert-unpooled.js +++ b/benchmark/timers/timers-insert-unpooled.js @@ -10,14 +10,13 @@ const bench = common.createBenchmark(main, { function main({ direction, n }) { const timersList = []; - var i; bench.start(); if (direction === 'start') { - for (i = 1; i <= n; i++) { + for (let i = 1; i <= n; i++) { timersList.push(setTimeout(cb, i)); } } else { - for (i = n; i > 0; i--) { + for (let i = n; i > 0; i--) { timersList.push(setTimeout(cb, i)); } }