@@ -13,9 +13,9 @@ import {
13
13
} from '@vue/runtime-dom'
14
14
import * as runtimeDom from '@vue/runtime-dom'
15
15
import {
16
- EMPTY_OBJ ,
17
16
NOOP ,
18
17
extend ,
18
+ genCacheKey ,
19
19
generateCodeFrame ,
20
20
isString ,
21
21
} from '@vue/shared'
@@ -25,19 +25,7 @@ if (__DEV__) {
25
25
initDev ( )
26
26
}
27
27
28
- const compileCache = new WeakMap <
29
- CompilerOptions ,
30
- Record < string , RenderFunction >
31
- > ( )
32
-
33
- function getCache ( options ?: CompilerOptions ) {
34
- let c = compileCache . get ( options ?? EMPTY_OBJ )
35
- if ( ! c ) {
36
- c = Object . create ( null ) as Record < string , RenderFunction >
37
- compileCache . set ( options ?? EMPTY_OBJ , c )
38
- }
39
- return c
40
- }
28
+ const compileCache : Record < string , RenderFunction > = Object . create ( null )
41
29
42
30
function compileToFunction (
43
31
template : string | HTMLElement ,
@@ -52,9 +40,8 @@ function compileToFunction(
52
40
}
53
41
}
54
42
55
- const key = template
56
- const cache = getCache ( options )
57
- const cached = cache [ key ]
43
+ const key = genCacheKey ( template , options )
44
+ const cached = compileCache [ key ]
58
45
if ( cached ) {
59
46
return cached
60
47
}
@@ -111,7 +98,7 @@ function compileToFunction(
111
98
// mark the function as runtime compiled
112
99
; ( render as InternalRenderFunction ) . _rc = true
113
100
114
- return ( cache [ key ] = render )
101
+ return ( compileCache [ key ] = render )
115
102
}
116
103
117
104
registerRuntimeCompiler ( compileToFunction )
0 commit comments