File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -10,29 +10,28 @@ export function memoize3<
10
10
let cache0 ;
11
11
12
12
return function memoized ( a1 , a2 , a3 ) {
13
- if ( ! cache0 ) {
13
+ if ( cache0 === undefined ) {
14
14
cache0 = new WeakMap ( ) ;
15
15
}
16
+
16
17
let cache1 = cache0 . get ( a1 ) ;
17
- let cache2 ;
18
- if ( cache1 ) {
19
- cache2 = cache1 . get ( a2 ) ;
20
- if ( cache2 ) {
21
- const cachedValue = cache2 . get ( a3 ) ;
22
- if ( cachedValue !== undefined ) {
23
- return cachedValue ;
24
- }
25
- }
26
- } else {
18
+ if ( cache1 === undefined ) {
27
19
cache1 = new WeakMap ( ) ;
28
20
cache0 . set ( a1 , cache1 ) ;
29
21
}
30
- if ( ! cache2 ) {
22
+
23
+ let cache2 = cache1 . get ( a2 ) ;
24
+ if ( cache2 === undefined ) {
31
25
cache2 = new WeakMap ( ) ;
32
26
cache1 . set ( a2 , cache2 ) ;
33
27
}
34
- const newValue = fn ( a1 , a2 , a3 ) ;
35
- cache2 . set ( a3 , newValue ) ;
36
- return newValue ;
28
+
29
+ let fnResult = cache2 . get ( a3 ) ;
30
+ if ( fnResult === undefined ) {
31
+ fnResult = fn ( a1 , a2 , a3 ) ;
32
+ cache2 . set ( a3 , fnResult ) ;
33
+ }
34
+
35
+ return fnResult ;
37
36
} ;
38
37
}
You can’t perform that action at this time.
0 commit comments