mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
benchmark: use let instead of var
Use `let` in module, napi, net, os, path, process, querystring, streams and string_decoder. PR-URL: https://github.com/nodejs/node/pull/31592 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
committed by
Anna Henningsen
parent
d0ed431041
commit
4bf888d3d2
@@ -14,12 +14,11 @@ const ASC_ALPHA = 'Blueberry jam';
|
||||
const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le');
|
||||
|
||||
function main({ encoding, inLen, chunkLen, n }) {
|
||||
var alpha;
|
||||
var buf;
|
||||
let alpha;
|
||||
let buf;
|
||||
const chunks = [];
|
||||
var str = '';
|
||||
let str = '';
|
||||
const isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8');
|
||||
var i;
|
||||
|
||||
if (encoding === 'ascii' || encoding === 'base64-ascii')
|
||||
alpha = ASC_ALPHA;
|
||||
@@ -33,7 +32,7 @@ function main({ encoding, inLen, chunkLen, n }) {
|
||||
|
||||
const sd = new StringDecoder(isBase64 ? 'base64' : encoding);
|
||||
|
||||
for (i = 0; i < inLen; ++i) {
|
||||
for (let i = 0; i < inLen; ++i) {
|
||||
if (i > 0 && (i % chunkLen) === 0 && !isBase64) {
|
||||
if (alpha) {
|
||||
chunks.push(Buffer.from(str, encoding));
|
||||
@@ -46,8 +45,8 @@ function main({ encoding, inLen, chunkLen, n }) {
|
||||
if (alpha)
|
||||
str += alpha[i % alpha.length];
|
||||
else {
|
||||
var start = i;
|
||||
var end = i + 2;
|
||||
let start = i;
|
||||
let end = i + 2;
|
||||
if (i % 2 !== 0) {
|
||||
++start;
|
||||
++end;
|
||||
@@ -77,8 +76,8 @@ function main({ encoding, inLen, chunkLen, n }) {
|
||||
const nChunks = chunks.length;
|
||||
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (var j = 0; j < nChunks; ++j)
|
||||
for (let i = 0; i < n; ++i) {
|
||||
for (let j = 0; j < nChunks; ++j)
|
||||
sd.write(chunks[j]);
|
||||
}
|
||||
bench.end(n);
|
||||
|
||||
Reference in New Issue
Block a user