Skip to content

Commit 4238460

Browse files
author
Myles Borins
committed
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. Ref: #9553 PR-URL: #8873 Reviewed-By: Brian White <[email protected]> Reviewed-By: Ilkka Myller <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 84849f1 commit 4238460

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

‎lib/_stream_readable.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,14 @@ Readable.prototype.unpipe = function(dest){
654654
state.pipesCount=0;
655655
state.flowing=false;
656656

657-
for(leti=0;i<len;i++)
657+
for(vari=0;i<len;i++)
658658
dests[i].emit('unpipe',this);
659659
returnthis;
660660
}
661661

662662
// try to find the right one.
663-
consti=state.pipes.indexOf(dest);
664-
if(i===-1)
663+
constindex=state.pipes.indexOf(dest);
664+
if(index===-1)
665665
returnthis;
666666

667667
state.pipes.splice(i,1);

‎lib/_tls_common.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ exports.SecureContext = SecureContext;
3434

3535
exports.createSecureContext=functioncreateSecureContext(options,context){
3636
if(!options)options={};
37+
vari;
38+
varlen;
3739

3840
varsecureOptions=options.secureOptions;
3941
if(options.honorCipherOrder)
@@ -47,7 +49,7 @@ exports.createSecureContext = function createSecureContext(options, context){
4749
// cert's issuer in C++ code.
4850
if(options.ca){
4951
if(Array.isArray(options.ca)){
50-
for(leti=0,len=options.ca.length;i<len;i++){
52+
for(i=0,len=options.ca.length;i<len;i++){
5153
c.context.addCACert(options.ca[i]);
5254
}
5355
}else{
@@ -59,7 +61,7 @@ exports.createSecureContext = function createSecureContext(options, context){
5961

6062
if(options.cert){
6163
if(Array.isArray(options.cert)){
62-
for(leti=0;i<options.cert.length;i++)
64+
for(i=0;i<options.cert.length;i++)
6365
c.context.setCert(options.cert[i]);
6466
}else{
6567
c.context.setCert(options.cert);
@@ -72,7 +74,7 @@ exports.createSecureContext = function createSecureContext(options, context){
7274
// which leads to the crash later on.
7375
if(options.key){
7476
if(Array.isArray(options.key)){
75-
for(leti=0;i<options.key.length;i++){
77+
for(i=0;i<options.key.length;i++){
7678
varkey=options.key[i];
7779

7880
if(key.passphrase)
@@ -103,7 +105,7 @@ exports.createSecureContext = function createSecureContext(options, context){
103105

104106
if(options.crl){
105107
if(Array.isArray(options.crl)){
106-
for(leti=0,len=options.crl.length;i<len;i++){
108+
for(i=0,len=options.crl.length;i<len;i++){
107109
c.context.addCRL(options.crl[i]);
108110
}
109111
}else{

‎lib/repl.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function REPLServer(prompt,
286286

287287
// After executing the current expression, store the values of RegExp
288288
// predefined properties back in `savedRegExMatches`
289-
for(letidx=1;idx<savedRegExMatches.length;idx+=1){
289+
for(varidx=1;idx<savedRegExMatches.length;idx+=1){
290290
savedRegExMatches[idx]=RegExp[`$${idx}`];
291291
}
292292

‎lib/tls.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function check(hostParts, pattern, wildcards){
9090
returnfalse;
9191

9292
// Check host parts from right to left first.
93-
for(leti=hostParts.length-1;i>0;i-=1)
93+
for(vari=hostParts.length-1;i>0;i-=1)
9494
if(hostParts[i]!==patternParts[i])
9595
returnfalse;
9696

‎lib/url.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost){
8989
if(typeofurl!=='string'){
9090
thrownewTypeError("Parameter 'url' must be a string, not "+typeofurl);
9191
}
92-
92+
vari,j,k,l;
9393
// Copy chrome, IE, opera backslash-handling behavior.
9494
// Back slashes before the query string get converted to forward slashes
9595
// See: https://code.google.com/p/chromium/issues/detail?id=25916
@@ -169,7 +169,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost){
169169

170170
// find the first instance of any hostEndingChars
171171
varhostEnd=-1;
172-
for(leti=0;i<hostEndingChars.length;i++){
172+
for(i=0;i<hostEndingChars.length;i++){
173173
consthec=rest.indexOf(hostEndingChars[i]);
174174
if(hec!==-1&&(hostEnd===-1||hec<hostEnd))
175175
hostEnd=hec;
@@ -197,7 +197,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost){
197197

198198
// the host is the remaining to the left of the first non-host char
199199
hostEnd=-1;
200-
for(leti=0;i<nonHostChars.length;i++){
200+
for(i=0;i<nonHostChars.length;i++){
201201
consthec=rest.indexOf(nonHostChars[i]);
202202
if(hec!==-1&&(hostEnd===-1||hec<hostEnd))
203203
hostEnd=hec;
@@ -224,12 +224,12 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost){
224224
// validate a little.
225225
if(!ipv6Hostname){
226226
varhostparts=this.hostname.split(/\./);
227-
for(leti=0,l=hostparts.length;i<l;i++){
227+
for(i=0,l=hostparts.length;i<l;i++){
228228
varpart=hostparts[i];
229229
if(!part)continue;
230230
if(!part.match(hostnamePartPattern)){
231231
varnewpart='';
232-
for(letj=0,k=part.length;j<k;j++){
232+
for(j=0,k=part.length;j<k;j++){
233233
if(part.charCodeAt(j)>127){
234234
// we replace non-ASCII char with a temporary placeholder
235235
// we need this to make sure size of hostname is not
@@ -294,7 +294,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost){
294294
// First, make 100% sure that any "autoEscape" chars get
295295
// escaped, even if encodeURIComponent doesn't think they
296296
// need to be.
297-
for(leti=0,l=autoEscape.length;i<l;i++){
297+
for(i=0,l=autoEscape.length;i<l;i++){
298298
varae=autoEscape[i];
299299
if(rest.indexOf(ae)===-1)
300300
continue;

0 commit comments

Comments
(0)