This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -550,19 +550,31 @@ Parser.prototype = {
550550 filter : function ( ) {
551551 var token = this . expect ( ) ;
552552 var fn = this . $filter ( token . text ) ;
553- var argsFn = [ ] ;
554- while ( this . expect ( ':' ) ) {
555- argsFn . push ( this . expression ( ) ) ;
556- }
557- return valueFn ( fnInvoke ) ;
553+ var argsFn ;
554+ var args ;
558555
559- function fnInvoke ( self , locals , input ) {
560- var args = [ input ] ;
561- for ( var i = 0 ; i < argsFn . length ; i ++ ) {
562- args . push ( argsFn [ i ] ( self , locals ) ) ;
556+ if ( this . peek ( ':' ) ) {
557+ argsFn = [ ] ;
558+ args = [ ] ; // we can safely reuse the array
559+ while ( this . expect ( ':' ) ) {
560+ argsFn . push ( this . expression ( ) ) ;
563561 }
564- return fn . apply ( self , args ) ;
565562 }
563+
564+ return valueFn ( function $parseFilter ( self , locals , input ) {
565+ if ( args ) {
566+ args [ 0 ] = input ;
567+
568+ var i = argsFn . length ;
569+ while ( i -- ) {
570+ args [ i + 1 ] = argsFn [ i ] ( self , locals ) ;
571+ }
572+
573+ return fn . apply ( self , args ) ;
574+ }
575+
576+ return fn . call ( self , input ) ;
577+ } ) ;
566578 } ,
567579
568580 expression : function ( ) {
You can’t perform that action at this time.
0 commit comments