mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
benchmark: refactor to eliminate redeclared vars
In order to comply with linting rules used in the rest of the code base, eliminate redeclared variables. A conservative approach is used so as to avoid unintentional performance issues (for example, as might be seen in some situations when using `let` instead of `var`). PR-URL: https://github.com/nodejs/node/pull/5468 Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
@@ -22,6 +22,7 @@ function main(conf) {
|
||||
var chunks = [];
|
||||
var str = '';
|
||||
var isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8');
|
||||
var i;
|
||||
|
||||
if (encoding === 'ascii' || encoding === 'base64-ascii')
|
||||
alpha = ASC_ALPHA;
|
||||
@@ -32,7 +33,7 @@ function main(conf) {
|
||||
|
||||
var sd = new StringDecoder(isBase64 ? 'base64' : encoding);
|
||||
|
||||
for (var i = 0; i < inLen; ++i) {
|
||||
for (i = 0; i < inLen; ++i) {
|
||||
if (i > 0 && (i % chunkLen) === 0 && !isBase64) {
|
||||
chunks.push(new Buffer(str, encoding));
|
||||
str = '';
|
||||
@@ -53,7 +54,7 @@ function main(conf) {
|
||||
var nChunks = chunks.length;
|
||||
|
||||
bench.start();
|
||||
for (var i = 0; i < n; ++i) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (var j = 0; j < nChunks; ++j)
|
||||
sd.write(chunks[j]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user