push
github
4 of 4 new or added lines in 1 file covered. (100.0%)
34 existing lines in 8 files now uncovered.2896 of 3426 relevant lines covered (84.53%)
10424.55 hits per line
1 |
package utils
|
|
2 |
|
|
3 |
func Cached1In1Out[I comparable, O any](f func(I) O) func(I) O { |
48✔ |
4 |
cache := make(map[I]O) |
48✔ |
5 |
return func(x I) O { |
12,790✔ |
6 |
if _, ok := cache[x]; !ok {
|
13,847✔ |
7 |
cache[x] = f(x) |
1,105✔ |
8 |
} |
1,105✔ |
9 |
value, _ := cache[x] |
12,742✔ |
10 |
return value
|
12,742✔ |
11 |
} |
|
12 |
} |
|
13 |
|
|
14 |
type out2[O1 any, O2 any] struct { |
|
15 |
o1 O1 |
|
16 |
o2 O2 |
|
17 |
} |
|
18 |
|
|
19 |
func Cached1In2OutErr[I comparable, O1 any, O2 any](f func(I) (O1, O2, error)) func(I) (O1, O2, error) { |
4✔ |
20 |
cache := make(map[I]out2[O1, O2]) |
4✔ |
21 |
return func(x I) (O1, O2, error) { |
114✔ |
22 |
if _, ok := cache[x]; !ok {
|
118✔ |
23 |
o1, o2, err := f(x) |
8✔ |
24 |
if err != nil { |
8✔ |
UNCOV
25
|
return o1, o2, err
|
× |
UNCOV
26
|
} |
× |
27 |
cache[x] = out2[O1, O2]{o1, o2} |
8✔ |
28 |
} |
|
29 |
value, _ := cache[x] |
110✔ |
30 |
return value.o1, value.o2, nil |
110✔ |
31 |
} |
|
32 |
} |