@@ -245,15 +245,16 @@ export function guidFor(obj) {
245245}
246246
247247const HAS_SUPER_PATTERN = / \. ( _ s u p e r | c a l l \( t h i s | a p p l y \( t h i s ) / ;
248+ const fnToString = Function . prototype . toString ;
248249
249250export const checkHasSuper = ( function ( ) {
250- let sourceAvailable = ( function ( ) {
251+ let sourceAvailable = fnToString . call ( function ( ) {
251252 return this ;
252- } ) . toString ( ) . indexOf ( 'return this' ) > - 1 ;
253+ } ) . indexOf ( 'return this' ) > - 1 ;
253254
254255 if ( sourceAvailable ) {
255256 return function checkHasSuper ( func ) {
256- return HAS_SUPER_PATTERN . test ( func . toString ( ) ) ;
257+ return HAS_SUPER_PATTERN . test ( fnToString . call ( func ) ) ;
257258 } ;
258259 }
259260
@@ -297,26 +298,9 @@ export function wrap(func, superFunc) {
297298
298299function _wrap ( func , superFunc ) {
299300 function superWrapper ( ) {
300- let orig = this . _super ;
301- let ret ;
301+ var orig = this . _super ;
302302 this . _super = superFunc ;
303- switch ( arguments . length ) {
304- case 0 : ret = func . call ( this ) ; break ;
305- case 1 : ret = func . call ( this , arguments [ 0 ] ) ; break ;
306- case 2 : ret = func . call ( this , arguments [ 0 ] , arguments [ 1 ] ) ; break ;
307- case 3 : ret = func . call ( this , arguments [ 0 ] , arguments [ 1 ] , arguments [ 2 ] ) ; break ;
308- case 4 : ret = func . call ( this , arguments [ 0 ] , arguments [ 1 ] , arguments [ 2 ] , arguments [ 3 ] ) ; break ;
309- case 5 : ret = func . call ( this , arguments [ 0 ] , arguments [ 1 ] , arguments [ 2 ] , arguments [ 3 ] , arguments [ 4 ] ) ; break ;
310- default :
311- // v8 bug potentially incorrectly deopts this function: https://code.google.com/p/v8/issues/detail?id=3709
312- // we may want to keep this around till this ages out on mobile
313- let args = new Array ( arguments . length ) ;
314- for ( var x = 0 ; x < arguments . length ; x ++ ) {
315- args [ x ] = arguments [ x ] ;
316- }
317- ret = func . apply ( this , args ) ;
318- break ;
319- }
303+ var ret = func . apply ( this , arguments ) ;
320304 this . _super = orig ;
321305 return ret ;
322306 }
@@ -464,27 +448,6 @@ export function inspect(obj) {
464448 return '{' + ret . join ( ', ' ) + '}' ;
465449}
466450
467- // The following functions are intentionally minified to keep the functions
468- // below Chrome's function body size inlining limit of 600 chars.
469- /**
470- @param {Object } t target
471- @param {Function } m method
472- @param {Array } a args
473- @private
474- */
475- export function apply ( t , m , a ) {
476- var l = a && a . length ;
477- if ( ! a || ! l ) { return m . call ( t ) ; }
478- switch ( l ) {
479- case 1 : return m . call ( t , a [ 0 ] ) ;
480- case 2 : return m . call ( t , a [ 0 ] , a [ 1 ] ) ;
481- case 3 : return m . call ( t , a [ 0 ] , a [ 1 ] , a [ 2 ] ) ;
482- case 4 : return m . call ( t , a [ 0 ] , a [ 1 ] , a [ 2 ] , a [ 3 ] ) ;
483- case 5 : return m . call ( t , a [ 0 ] , a [ 1 ] , a [ 2 ] , a [ 3 ] , a [ 4 ] ) ;
484- default : return m . apply ( t , a ) ;
485- }
486- }
487-
488451/**
489452 @param {Object } t target
490453 @param {String } m method
0 commit comments