File tree 1 file changed +22
-10
lines changed
1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -550,19 +550,31 @@ Parser.prototype = {
550
550
filter : function ( ) {
551
551
var token = this . expect ( ) ;
552
552
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 ;
558
555
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 ( ) ) ;
563
561
}
564
- return fn . apply ( self , args ) ;
565
562
}
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
+ } ) ;
566
578
} ,
567
579
568
580
expression : function ( ) {
You can’t perform that action at this time.
0 commit comments