File tree Expand file tree Collapse file tree 1 file changed +7
-21
lines changed
Expand file tree Collapse file tree 1 file changed +7
-21
lines changed Original file line number Diff line number Diff line change 1414import { MINI } from './constants.mjs' ;
1515import { build , evaluate } from './build.mjs' ;
1616
17- const getCacheMap = ( statics ) => {
18- let tpl = CACHE . get ( statics ) ;
19- if ( ! tpl ) {
20- CACHE . set ( statics , tpl = build ( statics ) ) ;
21- }
22- return tpl ;
23- } ;
24-
25- const getCacheKeyed = ( statics ) => {
26- let key = '' ;
27- for ( let i = 0 ; i < statics . length ; i ++ ) {
28- key += statics [ i ] . length + '-' + statics [ i ] ;
29- }
30- return CACHE [ key ] || ( CACHE [ key ] = build ( statics ) ) ;
31- } ;
32-
33- const USE_MAP = ! MINI && typeof Map === 'function' ;
34- const CACHE = USE_MAP ? new Map ( ) : { } ;
35- const getCache = USE_MAP ? getCacheMap : getCacheKeyed ;
17+ const CACHE = new Map ( ) ;
3618
3719const cached = function ( statics ) {
38- const res = evaluate ( this , getCache ( statics ) , arguments , [ ] ) ;
39- return res . length > 1 ? res : res [ 0 ] ;
20+ let tmp = CACHE . get ( statics ) ;
21+ if ( ! tmp ) {
22+ CACHE . set ( statics , tmp = build ( statics ) ) ;
23+ }
24+ tmp = evaluate ( this , tmp , arguments , [ ] ) ;
25+ return tmp . length > 1 ? tmp : tmp [ 0 ] ;
4026} ;
4127
4228export default MINI ? build : cached ;
You can’t perform that action at this time.
0 commit comments