Skip to content

Commit b556670

Browse files
dnlupaddaleax
authored andcommitted
benchmark: use let instead of var in zlib
PR-URL: #31794 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent d831665 commit b556670

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

benchmark/zlib/creation.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ function main({ n, type, options }) {
1515
const fn = zlib[`create${type}`];
1616
if (typeof fn !== 'function')
1717
throw new Error('Invalid zlib type');
18-
var i = 0;
1918

2019
if (options === 'true') {
2120
const opts = {};
2221
bench.start();
23-
for (; i < n; ++i)
22+
for (let i = 0; i < n; ++i)
2423
fn(opts);
2524
bench.end(n);
2625
} else {
2726
bench.start();
28-
for (; i < n; ++i)
27+
for (let i = 0; i < n; ++i)
2928
fn();
3029
bench.end(n);
3130
}

benchmark/zlib/deflate.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ function main({ n, method, inputLen }) {
1313
method = method || 'deflate';
1414
const chunk = Buffer.alloc(inputLen, 'a');
1515

16-
var i = 0;
1716
switch (method) {
1817
// Performs `n` writes for a single deflate stream
19-
case 'createDeflate':
20-
var deflater = zlib.createDeflate();
18+
case 'createDeflate': {
19+
let i = 0;
20+
const deflater = zlib.createDeflate();
2121
deflater.resume();
2222
deflater.on('finish', () => {
2323
bench.end(n);
@@ -30,24 +30,28 @@ function main({ n, method, inputLen }) {
3030
deflater.write(chunk, next);
3131
})();
3232
break;
33+
}
3334
// Performs `n` single deflate operations
34-
case 'deflate':
35-
var deflate = zlib.deflate;
35+
case 'deflate': {
36+
let i = 0;
37+
const deflate = zlib.deflate;
3638
bench.start();
3739
(function next(err, result) {
3840
if (i++ === n)
3941
return bench.end(n);
4042
deflate(chunk, next);
4143
})();
4244
break;
45+
}
4346
// Performs `n` single deflateSync operations
44-
case 'deflateSync':
45-
var deflateSync = zlib.deflateSync;
47+
case 'deflateSync': {
48+
const deflateSync = zlib.deflateSync;
4649
bench.start();
47-
for (; i < n; ++i)
50+
for (let i = 0; i < n; ++i)
4851
deflateSync(chunk);
4952
bench.end(n);
5053
break;
54+
}
5155
default:
5256
throw new Error('Unsupported deflate method');
5357
}

0 commit comments

Comments
 (0)