lib: remove let from for loops
This is a known de-opt. It may not be 100% necessary in all cases but it seems like a decent enough idea to avoid it. PR-URL: https://github.com/nodejs/node/pull/8873 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
7420835390
commit
2e568d95bd
@ -661,14 +661,14 @@ Readable.prototype.unpipe = function(dest) {
|
|||||||
state.pipesCount = 0;
|
state.pipesCount = 0;
|
||||||
state.flowing = false;
|
state.flowing = false;
|
||||||
|
|
||||||
for (let i = 0; i < len; i++)
|
for (var i = 0; i < len; i++)
|
||||||
dests[i].emit('unpipe', this);
|
dests[i].emit('unpipe', this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to find the right one.
|
// try to find the right one.
|
||||||
const i = state.pipes.indexOf(dest);
|
const index = state.pipes.indexOf(dest);
|
||||||
if (i === -1)
|
if (index === -1)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
state.pipes.splice(i, 1);
|
state.pipes.splice(i, 1);
|
||||||
|
@ -26,7 +26,7 @@ function getStringWidth(str) {
|
|||||||
|
|
||||||
str = stripVTControlCharacters(str);
|
str = stripVTControlCharacters(str);
|
||||||
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
const code = str.codePointAt(i);
|
const code = str.codePointAt(i);
|
||||||
|
|
||||||
if (code >= 0x10000) { // surrogates
|
if (code >= 0x10000) { // surrogates
|
||||||
|
@ -24,7 +24,7 @@ exports.error = function(msg) {
|
|||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
const args = new Array(arguments.length);
|
const args = new Array(arguments.length);
|
||||||
args[0] = fmt;
|
args[0] = fmt;
|
||||||
for (let i = 1; i < arguments.length; ++i)
|
for (var i = 1; i < arguments.length; ++i)
|
||||||
args[i] = arguments[i];
|
args[i] = arguments[i];
|
||||||
console.error.apply(console, args);
|
console.error.apply(console, args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +210,7 @@ const decode = function(input) {
|
|||||||
basic = 0;
|
basic = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let j = 0; j < basic; ++j) {
|
for (var j = 0; j < basic; ++j) {
|
||||||
// if it's not a basic code point
|
// if it's not a basic code point
|
||||||
if (input.charCodeAt(j) >= 0x80) {
|
if (input.charCodeAt(j) >= 0x80) {
|
||||||
error('not-basic');
|
error('not-basic');
|
||||||
@ -221,7 +221,7 @@ const decode = function(input) {
|
|||||||
// Main decoding loop: start just after the last delimiter if any basic code
|
// Main decoding loop: start just after the last delimiter if any basic code
|
||||||
// points were copied; start at the beginning otherwise.
|
// points were copied; start at the beginning otherwise.
|
||||||
|
|
||||||
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
for (var index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
||||||
|
|
||||||
// `index` is the index of the next character to be consumed.
|
// `index` is the index of the next character to be consumed.
|
||||||
// Decode a generalized variable-length integer into `delta`,
|
// Decode a generalized variable-length integer into `delta`,
|
||||||
@ -229,7 +229,7 @@ const decode = function(input) {
|
|||||||
// if we increase `i` as we go, then subtract off its starting
|
// if we increase `i` as we go, then subtract off its starting
|
||||||
// value at the end to obtain `delta`.
|
// value at the end to obtain `delta`.
|
||||||
let oldi = i;
|
let oldi = i;
|
||||||
for (let w = 1, k = base; /* no condition */; k += base) {
|
for (var w = 1, k = base; /* no condition */; k += base) {
|
||||||
|
|
||||||
if (index >= inputLength) {
|
if (index >= inputLength) {
|
||||||
error('invalid-input');
|
error('invalid-input');
|
||||||
@ -345,7 +345,7 @@ const encode = function(input) {
|
|||||||
if (currentValue == n) {
|
if (currentValue == n) {
|
||||||
// Represent delta as a generalized variable-length integer.
|
// Represent delta as a generalized variable-length integer.
|
||||||
let q = delta;
|
let q = delta;
|
||||||
for (let k = base; /* no condition */; k += base) {
|
for (var k = base; /* no condition */; k += base) {
|
||||||
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||||
if (q < t) {
|
if (q < t) {
|
||||||
break;
|
break;
|
||||||
|
@ -345,7 +345,7 @@ function REPLServer(prompt,
|
|||||||
|
|
||||||
// After executing the current expression, store the values of RegExp
|
// After executing the current expression, store the values of RegExp
|
||||||
// predefined properties back in `savedRegExMatches`
|
// predefined properties back in `savedRegExMatches`
|
||||||
for (let idx = 1; idx < savedRegExMatches.length; idx += 1) {
|
for (var idx = 1; idx < savedRegExMatches.length; idx += 1) {
|
||||||
savedRegExMatches[idx] = RegExp[`$${idx}`];
|
savedRegExMatches[idx] = RegExp[`$${idx}`];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1078,9 +1078,9 @@ function longestCommonPrefix(arr = []) {
|
|||||||
|
|
||||||
const first = arr[0];
|
const first = arr[0];
|
||||||
// complexity: O(m * n)
|
// complexity: O(m * n)
|
||||||
for (let m = 0; m < first.length; m++) {
|
for (var m = 0; m < first.length; m++) {
|
||||||
const c = first[m];
|
const c = first[m];
|
||||||
for (let n = 1; n < cnt; n++) {
|
for (var n = 1; n < cnt; n++) {
|
||||||
const entry = arr[n];
|
const entry = arr[n];
|
||||||
if (m >= entry.length || c !== entry[m]) {
|
if (m >= entry.length || c !== entry[m]) {
|
||||||
return first.substring(0, m);
|
return first.substring(0, m);
|
||||||
|
@ -100,7 +100,7 @@ function check(hostParts, pattern, wildcards) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check host parts from right to left first.
|
// Check host parts from right to left first.
|
||||||
for (let i = hostParts.length - 1; i > 0; i -= 1)
|
for (var i = hostParts.length - 1; i > 0; i -= 1)
|
||||||
if (hostParts[i] !== patternParts[i])
|
if (hostParts[i] !== patternParts[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ if (typeof global.SIMD === 'object' && global.SIMD !== null) {
|
|||||||
const make = (extractLane, count) => {
|
const make = (extractLane, count) => {
|
||||||
return (ctx, value, recurseTimes, visibleKeys, keys) => {
|
return (ctx, value, recurseTimes, visibleKeys, keys) => {
|
||||||
const output = new Array(count);
|
const output = new Array(count);
|
||||||
for (let i = 0; i < count; i += 1)
|
for (var i = 0; i < count; i += 1)
|
||||||
output[i] = formatPrimitive(ctx, extractLane(value, i));
|
output[i] = formatPrimitive(ctx, extractLane(value, i));
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ exports.getHeapSpaceStatistics = function() {
|
|||||||
const buffer = heapSpaceStatisticsBuffer;
|
const buffer = heapSpaceStatisticsBuffer;
|
||||||
v8binding.updateHeapSpaceStatisticsArrayBuffer();
|
v8binding.updateHeapSpaceStatisticsArrayBuffer();
|
||||||
|
|
||||||
for (let i = 0; i < kNumberOfHeapSpaces; i++) {
|
for (var i = 0; i < kNumberOfHeapSpaces; i++) {
|
||||||
const propertyOffset = i * kHeapSpaceStatisticsPropertiesCount;
|
const propertyOffset = i * kHeapSpaceStatisticsPropertiesCount;
|
||||||
heapSpaceStatistics[i] = {
|
heapSpaceStatistics[i] = {
|
||||||
space_name: kHeapSpaces[i],
|
space_name: kHeapSpaces[i],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user