File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,13 @@ package modver
3
3
import "go/types"
4
4
5
5
// https://golang.org/ref/spec#Type_identity
6
- func (c * comparer ) identical (a , b types.Type ) bool {
6
+ func (c * comparer ) identical (a , b types.Type ) (res bool ) {
7
+ tp := typePair {a : a , b : b }
8
+ if res , ok := c .identicache [tp ]; ok {
9
+ return res
10
+ }
11
+ defer func () { c .identicache [tp ] = res }()
12
+
7
13
if types .Identical (a , b ) {
8
14
return true
9
15
}
Original file line number Diff line number Diff line change @@ -12,14 +12,18 @@ import (
12
12
13
13
type (
14
14
comparer struct {
15
- stack []typePair
16
- cache map [typePair ]Result
15
+ stack []typePair
16
+ cache map [typePair ]Result
17
+ identicache map [typePair ]bool
17
18
}
18
19
typePair struct { a , b types.Type }
19
20
)
20
21
21
22
func newComparer () * comparer {
22
- return & comparer {cache : make (map [typePair ]Result )}
23
+ return & comparer {
24
+ cache : make (map [typePair ]Result ),
25
+ identicache : make (map [typePair ]bool ),
26
+ }
23
27
}
24
28
25
29
func (c * comparer ) compareTypes (older , newer types.Type ) (res Result ) {
You can’t perform that action at this time.
0 commit comments