@@ -408,14 +408,16 @@ Parser.prototype.walkMethodDefinition = function walkMethodDefinition(methodDefi
408408} ;
409409
410410Parser . prototype . walkStatements = function walkStatements ( statements ) {
411- statements . forEach ( function ( statement ) {
412- if ( this . isHoistedStatement ( statement ) )
413- this . walkStatement ( statement ) ;
414- } , this ) ;
415- statements . forEach ( function ( statement ) {
416- if ( ! this . isHoistedStatement ( statement ) )
417- this . walkStatement ( statement ) ;
418- } , this ) ;
411+ for ( var indexA = 0 , lenA = statements . length ; indexA < lenA ; indexA ++ ) {
412+ var statementA = statements [ indexA ] ;
413+ if ( this . isHoistedStatement ( statementA ) )
414+ this . walkStatement ( statementA ) ;
415+ }
416+ for ( var indexB = 0 , lenB = statements . length ; indexB < lenB ; indexB ++ ) {
417+ var statementB = statements [ indexB ] ;
418+ if ( ! this . isHoistedStatement ( statementB ) )
419+ this . walkStatement ( statementB ) ;
420+ }
419421} ;
420422
421423Parser . prototype . isHoistedStatement = function isHoistedStatement ( statement ) {
@@ -580,24 +582,26 @@ Parser.prototype.walkExportNamedDeclaration = function walkExportNamedDeclaratio
580582 var pos = this . scope . definitions . length ;
581583 this . walkStatement ( statement . declaration ) ;
582584 var newDefs = this . scope . definitions . slice ( pos ) ;
583- newDefs . reverse ( ) . forEach ( function ( def , idx ) {
584- this . applyPluginsBailResult ( "export specifier" , statement , def , def , idx ) ;
585- } , this ) ;
585+ for ( var index = newDefs . length - 1 ; index >= 0 ; index -- ) {
586+ var def = newDefs [ index ] ;
587+ this . applyPluginsBailResult ( "export specifier" , statement , def , def , index ) ;
588+ }
586589 }
587590 }
588591 }
589592 if ( statement . specifiers ) {
590- statement . specifiers . forEach ( function ( specifier , idx ) {
593+ for ( var specifierIndex = 0 ; specifierIndex < statement . specifiers . length ; specifierIndex ++ ) {
594+ var specifier = statement . specifiers [ specifierIndex ] ;
591595 switch ( specifier . type ) {
592596 case "ExportSpecifier" :
593597 var name = specifier . exported . name ;
594598 if ( source )
595- this . applyPluginsBailResult ( "export import specifier" , statement , source , specifier . local . name , name , idx ) ;
599+ this . applyPluginsBailResult ( "export import specifier" , statement , source , specifier . local . name , name , specifierIndex ) ;
596600 else
597- this . applyPluginsBailResult ( "export specifier" , statement , specifier . local . name , name , idx ) ;
601+ this . applyPluginsBailResult ( "export specifier" , statement , specifier . local . name , name , specifierIndex ) ;
598602 break ;
599603 }
600- } , this ) ;
604+ }
601605 }
602606} ;
603607
@@ -608,9 +612,10 @@ Parser.prototype.walkExportDefaultDeclaration = function walkExportDefaultDeclar
608612 var pos = this . scope . definitions . length ;
609613 this . walkStatement ( statement . declaration ) ;
610614 var newDefs = this . scope . definitions . slice ( pos ) ;
611- newDefs . forEach ( function ( def ) {
615+ for ( var index = 0 , len = newDefs . length ; index < len ; index ++ ) {
616+ var def = newDefs [ index ] ;
612617 this . applyPluginsBailResult ( "export specifier" , statement , def , "default" ) ;
613- } , this ) ;
618+ }
614619 }
615620 } else {
616621 this . walkExpression ( statement . declaration ) ;
@@ -638,11 +643,14 @@ Parser.prototype.walkClassDeclaration = function walkClassDeclaration(statement)
638643} ;
639644
640645Parser . prototype . walkSwitchCases = function walkSwitchCases ( switchCases ) {
641- switchCases . forEach ( function ( switchCase ) {
642- if ( switchCase . test )
646+ for ( var index = 0 , len = switchCases . length ; index < len ; index ++ ) {
647+ var switchCase = switchCases [ index ] ;
648+
649+ if ( switchCase . test ) {
643650 this . walkExpression ( switchCase . test ) ;
651+ }
644652 this . walkStatements ( switchCase . consequent ) ;
645- } , this ) ;
653+ }
646654} ;
647655
648656Parser . prototype . walkCatchClause = function walkCatchClause ( catchClause ) {
@@ -682,10 +690,11 @@ Parser.prototype.walkVariableDeclarators = function walkVariableDeclarators(decl
682690} ;
683691
684692Parser . prototype . walkExpressions = function walkExpressions ( expressions ) {
685- expressions . forEach ( function ( expression ) {
693+ for ( var expressionsIndex = 0 , len = expressions . length ; expressionsIndex < len ; expressionsIndex ++ ) {
694+ var expression = expressions [ expressionsIndex ] ;
686695 if ( expression )
687696 this . walkExpression ( expression ) ;
688- } , this ) ;
697+ }
689698} ;
690699
691700Parser . prototype . walkExpression = function walkExpression ( expression ) {
@@ -710,15 +719,16 @@ Parser.prototype.walkSpreadElement = function walkSpreadElement(expression) {
710719} ;
711720
712721Parser . prototype . walkObjectExpression = function walkObjectExpression ( expression ) {
713- expression . properties . forEach ( function ( prop ) {
722+ for ( var propIndex = 0 , len = expression . properties . length ; propIndex < len ; propIndex ++ ) {
723+ var prop = expression . properties [ propIndex ] ;
714724 if ( prop . computed )
715725 this . walkExpression ( prop . key ) ;
716726 if ( prop . shorthand )
717727 this . scope . inShorthand = true ;
718728 this . walkExpression ( prop . value ) ;
719729 if ( prop . shorthand )
720730 this . scope . inShorthand = false ;
721- } , this ) ;
731+ }
722732} ;
723733
724734Parser . prototype . walkFunctionExpression = function walkFunctionExpression ( expression ) {
@@ -946,7 +956,10 @@ Parser.prototype.inScope = function inScope(params, fn) {
946956 definitions : oldScope . definitions . slice ( ) ,
947957 renames : Object . create ( oldScope . renames )
948958 } ;
949- params . forEach ( function ( param ) {
959+
960+ for ( var paramIndex = 0 , len = params . length ; paramIndex < len ; paramIndex ++ ) {
961+ var param = params [ paramIndex ] ;
962+
950963 if ( typeof param !== "string" ) {
951964 param = _this . enterPattern ( param , function ( param ) {
952965 _this . scope . renames [ "$" + param ] = undefined ;
@@ -956,7 +969,8 @@ Parser.prototype.inScope = function inScope(params, fn) {
956969 _this . scope . renames [ "$" + param ] = undefined ;
957970 _this . scope . definitions . push ( param ) ;
958971 }
959- } ) ;
972+ }
973+
960974 fn ( ) ;
961975 _this . scope = oldScope ;
962976} ;
@@ -971,15 +985,17 @@ Parser.prototype.enterIdentifier = function enterIdentifier(pattern, onIdent) {
971985} ;
972986
973987Parser . prototype . enterObjectPattern = function enterObjectPattern ( pattern , onIdent ) {
974- pattern . properties . forEach ( function ( property ) {
975- this . enterPattern ( property . value , onIdent ) ;
976- } , this ) ;
988+ for ( var propIndex = 0 , len = pattern . properties . length ; propIndex < len ; propIndex ++ ) {
989+ var prop = pattern . properties [ propIndex ] ;
990+ this . enterPattern ( prop . value , onIdent ) ;
991+ }
977992} ;
978993
979994Parser . prototype . enterArrayPattern = function enterArrayPattern ( pattern , onIdent ) {
980- pattern . elements . forEach ( function ( pattern ) {
981- this . enterPattern ( pattern , onIdent ) ;
982- } , this ) ;
995+ for ( var elementIndex = 0 , len = pattern . elements . length ; elementIndex < len ; elementIndex ++ ) {
996+ var element = pattern . elements [ elementIndex ] ;
997+ this . enterPattern ( element , onIdent ) ;
998+ }
983999} ;
9841000
9851001Parser . prototype . enterRestElement = function enterRestElement ( pattern , onIdent ) {
@@ -1107,7 +1123,7 @@ var POSSIBLE_AST_OPTIONS = [{
11071123
11081124Parser . prototype . parse = function parse ( source , initialState ) {
11091125 var ast , comments = [ ] ;
1110- for ( var i = 0 ; i < POSSIBLE_AST_OPTIONS . length ; i ++ ) {
1126+ for ( var i = 0 , len = POSSIBLE_AST_OPTIONS . length ; i < len ; i ++ ) {
11111127 if ( ! ast ) {
11121128 try {
11131129 comments . length = 0 ;
0 commit comments