File tree 1 file changed +13
-9
lines changed
1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -325,15 +325,19 @@ function parser(text, json){
325
325
if ( tokens . length > 0 && ! peek ( '}' , ')' , ';' , ']' ) )
326
326
statements . push ( filterChain ( ) ) ;
327
327
if ( ! expect ( ';' ) ) {
328
- return function ( self ) {
329
- var value ;
330
- for ( var i = 0 ; i < statements . length ; i ++ ) {
331
- var statement = statements [ i ] ;
332
- if ( statement )
333
- value = statement ( self ) ;
334
- }
335
- return value ;
336
- } ;
328
+ // optimize for the common case where there is only one statement.
329
+ // TODO(size): maybe we should not support multiple statements?
330
+ return statements . length == 1
331
+ ? statements [ 0 ]
332
+ : function ( self ) {
333
+ var value ;
334
+ for ( var i = 0 ; i < statements . length ; i ++ ) {
335
+ var statement = statements [ i ] ;
336
+ if ( statement )
337
+ value = statement ( self ) ;
338
+ }
339
+ return value ;
340
+ } ;
337
341
}
338
342
}
339
343
}
You can’t perform that action at this time.
0 commit comments