Debian Codegraph @

go/callgraph/vta/internal/trie/builder.go

raw symbols SCIP
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/
6
7 // Collision functions combine a left and right hand side (lhs and rhs) values
8 // the two values are associated with the same key and produces the value that
9 // will be stored for the key.
10 //
11 // Collision functions must be idempotent:
12 //
13 // collision(x, x) == x for all x.
14 //
15 // Collisions functions may be applied whenever a value is inserted
16 // or two maps are merged, or intersected.
17 type Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision# func(lhs any, rhs any) any
18
19 // TakeLhs always returns the left value in a collision.
20 func TakeLhsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/TakeLhs().(lhs, rhs any) any { return lhs }
21
22 // TakeRhs always returns the right hand side in a collision.
23 func TakeRhsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/TakeRhs().(lhs, rhs any) any { return rhs }
24
25 // Builder creates new Map. Each Builder has a unique Scope.
26 //
27 // IMPORTANT: Nodes are hash-consed internally to reduce memory consumption. To
28 // support hash-consing Builders keep an internal Map of all of the Maps that they
29 // have created. To GC any of the Maps created by the Builder, all references to
30 // the Builder must be dropped. This includes MutMaps.
31 type Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder# struct {
32 scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#scope. Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Scope#
33
34 // hash-consing maps for each node type.
35 emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty. *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#
36 leavesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#leaves. map[leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#]*leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#
37 branchesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#branches. map[branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#]*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#
38 // It may be possible to support more types of patricia tries
39 // (e.g. non-hash-consed) by making Builder an interface and abstracting
40 // the mkLeaf and mkBranch functions.
41 }
42
43 // NewBuilder creates a new Builder with a unique Scope.
44 func NewBuilderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/NewBuilder().() *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder# {
45 s := newScopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/newScope().()
46 return &Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#{
47 scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#scope.: s,
48 emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.: &emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#{s},
49 leavesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#leaves.: make(map[leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#]*leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#),
50 branchesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#branches.: make(map[branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#]*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#),
51 }
52 }
53
54 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().() Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Scope# { return b.scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#scope. }
55
56 // Rescope changes the builder's scope to a new unique Scope.
57 //
58 // Any Maps created using the previous scope need to be Cloned
59 // before any operation.
60 //
61 // This makes the old internals of the Builder eligible to be GC'ed.
62 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Rescopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Rescope().() {
63 s := newScopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/newScope().()
64 b.scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#scope. = s
65 b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty. = &emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#{s}
66 b.leavesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#leaves. = make(map[leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#]*leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#)
67 b.branchesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#branches. = make(map[branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#]*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#)
68 }
69
70 // Empty is the empty map.
71 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Empty().() Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# { return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.} }
72
73 // InsertWith inserts a new association from k to v into the Map m to create a new map
74 // in the current scope and handle collisions using the collision function c.
75 //
76 // This is roughly corresponds to updating a map[uint64]interface{} by:
77 //
78 // if _, ok := m[k]; ok { m[k] = c(m[k], v} else { m[k] = v}
79 //
80 // An insertion or update happened whenever Insert(m, ...) != m .
81 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) InsertWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#InsertWith().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, m Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#, k uint64, v any) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
82 m = b.Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(m)
83 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#insert().(c, m.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n., b.mkLeafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkLeaf().(keyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/key#(k), v), false)}
84 }
85
86 // Inserts a new association from key to value into the Map m to create
87 // a new map in the current scope.
88 //
89 // If there was a previous value mapped by key, keep the previously mapped value.
90 // This is roughly corresponds to updating a map[uint64]interface{} by:
91 //
92 // if _, ok := m[k]; ok { m[k] = val }
93 //
94 // This is equivalent to b.Merge(m, b.Create({k: v})).
95 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Insert().(m Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#, k uint64, v any) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
96 return b.InsertWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#InsertWith().(TakeLhsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/TakeLhs()., m, k, v)
97 }
98
99 // Updates a (key, value) in the map. This is roughly corresponds to
100 // updating a map[uint64]interface{} by:
101 //
102 // m[key] = val
103 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Update().(m Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#, key uint64, val any) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
104 return b.InsertWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#InsertWith().(TakeRhsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/TakeRhs()., m, key, val)
105 }
106
107 // Merge two maps lhs and rhs to create a new map in the current scope.
108 //
109 // Whenever there is a key in both maps (a collision), the resulting value mapped by
110 // the key will be `c(lhs[key], rhs[key])`.
111 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) MergeWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MergeWith().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, lhs, rhs Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
112 lhs, rhs = b.Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(lhs), b.Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(rhs)
113 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, lhs.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n., rhs.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n.)}
114 }
115
116 // Merge two maps lhs and rhs to create a new map in the current scope.
117 //
118 // Whenever there is a key in both maps (a collision), the resulting value mapped by
119 // the key will be the value in lhs `b.Collision(lhs[key], rhs[key])`.
120 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Merge().(lhs, rhs Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
121 return b.MergeWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MergeWith().(TakeLhsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/TakeLhs()., lhs, rhs)
122 }
123
124 // Clone returns a Map that contains the same (key, value) elements
125 // within b.Scope(), i.e. return m if m.Scope() == b.Scope() or return
126 // a deep copy of m within b.Scope() otherwise.
127 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(m Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
128 if m.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#Scope().() == b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().() {
129 return m
130 } else if m.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n. == nil {
131 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.}
132 }
133 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#clone().(m.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n.)}
134 }
135 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#clone().(n nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#) nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node# {
136 switch n := n.(type) {
137 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
138 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
139 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
140 return b.mkLeafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkLeaf().(n.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k., n.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#v.)
141 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
142 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(n.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., n.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching., b.clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#clone().(n.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left.), b.clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#clone().(n.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.))
143 default:
144 panic("unreachable")
145 }
146 }
147
148 // Remove a key from a Map m and return the resulting Map.
149 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Remove().(m Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#, k uint64) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
150 m = b.Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(m)
151 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#remove().(m.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n., keyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/key#(k))}
152 }
153
154 // Intersect Maps lhs and rhs and returns a map with all of the keys in
155 // both lhs and rhs and the value comes from lhs, i.e.
156 //
157 // {(k, lhs[k]) | k in lhs, k in rhs}.
158 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Intersect().(lhs, rhs Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
159 return b.IntersectWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#IntersectWith().(TakeLhsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/TakeLhs()., lhs, rhs)
160 }
161
162 // IntersectWith take lhs and rhs and returns the intersection
163 // with the value coming from the collision function, i.e.
164 //
165 // {(k, c(lhs[k], rhs[k]) ) | k in lhs, k in rhs}.
166 //
167 // The elements of the resulting map are always { <k, c(lhs[k], rhs[k]) > }
168 // for each key k that a key in both lhs and rhs.
169 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) IntersectWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#IntersectWith().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, lhs, rhs Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
170 l, r := b.Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(lhs), b.Clonescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Clone().(rhs)
171 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#intersect().(c, l.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n., r.nscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#n.)}
172 }
173
174 // MutMap is a convenient wrapper for a Map and a *Builder that will be used to create
175 // new Maps from it.
176 type MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap# struct {
177 Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B. *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#
178 Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#
179 }
180
181 // MutEmpty is an empty MutMap for a builder.
182 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) MutEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MutEmpty().() MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap# {
183 return MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#{b, b.Emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Empty().()}
184 }
185
186 // Insert an element into the map using the collision function for the builder.
187 // Returns true if the element was inserted.
188 func (mm *MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#) Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Insert().(k uint64, v any) bool {
189 old := mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
190 mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. = mm.Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B..Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Insert().(old, k, v)
191 return old != mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
192 }
193
194 // Updates an element in the map. Returns true if the map was updated.
195 func (mm *MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#) Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Update().(k uint64, v any) bool {
196 old := mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
197 mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. = mm.Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B..Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Update().(old, k, v)
198 return old != mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
199 }
200
201 // Removes a key from the map. Returns true if the element was removed.
202 func (mm *MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#) Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Remove().(k uint64) bool {
203 old := mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
204 mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. = mm.Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B..Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Remove().(old, k)
205 return old != mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
206 }
207
208 // Merge another map into the current one using the collision function
209 // for the builder. Returns true if the map changed.
210 func (mm *MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#) Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Merge().(other Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) bool {
211 old := mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
212 mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. = mm.Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B..Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Merge().(old, other)
213 return old != mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
214 }
215
216 // Intersect another map into the current one using the collision function
217 // for the builder. Returns true if the map changed.
218 func (mm *MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#) Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Intersect().(other Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) bool {
219 old := mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
220 mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. = mm.Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B..Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Intersect().(old, other)
221 return old != mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
222 }
223
224 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) Createscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Create().(m map[uint64]any) Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map# {
225 var leaves []*leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#
226 for k, v := range m {
227 leaves = append(leaves, b.mkLeafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkLeaf().(keyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/key#(k), v))
228 }
229 return Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#{b.Scopescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#Scope().(), b.createscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#create().(leaves)}
230 }
231
232 // Merge another map into the current one using the collision function
233 // for the builder. Returns true if the map changed.
234 func (mm *MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#) MergeWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#MergeWith().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, other Mapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#) bool {
235 old := mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
236 mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M. = mm.Bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#B..MergeWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MergeWith().(c, old, other)
237 return old != mm.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.
238 }
239
240 // creates a map for a collection of leaf nodes.
241 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) createscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#create().(leaves []*leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#) nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node# {
242 n := len(leaves)
243 if n == 0 {
244 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
245 } else if n == 1 {
246 return leaves[0]
247 }
248 // Note: we can do a more sophisticated algorithm by:
249 // - sorting the leaves ahead of time,
250 // - taking the prefix and branching bit of the min and max key,
251 // - binary searching for the branching bit,
252 // - splitting exactly where the branch will be, and
253 // - making the branch node for this prefix + branching bit.
254 // Skipping until this is a performance bottleneck.
255
256 m := n / 2 // (n >= 2) ==> 1 <= m < n
257 l, r := leaves[:m], leaves[m:]
258 return b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(nil, b.createscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#create().(l), b.createscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#create().(r))
259 }
260
261 // mkLeaf returns the hash-consed representative of (k, v) in the current scope.
262 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) mkLeafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkLeaf().(k keyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/key#, v any) *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf# {
263 rep, ok := b.leavesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#leaves.[leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#{k, v}]
264 if !ok {
265 rep = &leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#{k, v} // heap-allocated copy
266 b.leavesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#leaves.[leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#{k, v}] = rep
267 }
268 return rep
269 }
270
271 // mkBranch returns the hash-consed representative of the tuple
272 //
273 // (prefix, branch, left, right)
274 //
275 // in the current scope.
276 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(p prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#, bp bitposscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/bitpos#, left nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#, right nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#) *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch# {
277 br := branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#{
278 szscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#sz.: left.sizescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#size.() + right.sizescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#size.(),
279 prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix.: p,
280 branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.: bp,
281 leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left.: left,
282 rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.: right,
283 }
284 rep, ok := b.branchesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#branches.[br]
285 if !ok {
286 rep = new(branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#) // heap-allocated copy
287 *rep = br
288 b.branchesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#branches.[br] = rep
289 }
290 return rep
291 }
292
293 // join two maps with prefixes p0 and p1 that are *known* to disagree.
294 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) joinscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#join().(p0 prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#, t0 nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#, p1 prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#, t1 nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#) *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch# {
295 m := branchingBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branchingBit().(p0, p1)
296 var left, right nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#
297 if zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(p0, m) {
298 left, right = t0, t1
299 } else {
300 left, right = t1, t0
301 }
302 prefix := maskscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/mask().(p0, m)
303 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(prefix, m, left, right)
304 }
305
306 // collide two leaves with the same key to create a leaf
307 // with the collided value.
308 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) collidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#collide().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, left, right *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#) *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf# {
309 if left == right {
310 return left // c is idempotent: c(x, x) == x
311 }
312 val := left.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#v. // keep the left value by default if c is nil
313 if c != nil {
314 val = c(left.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#v., right.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#v.)
315 }
316 switch val {
317 case left.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#v.:
318 return left
319 case right.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#v.:
320 return right
321 default:
322 return b.mkLeafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkLeaf().(left.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k., val)
323 }
324 }
325
326 // inserts a leaf l into a map m and returns the resulting map.
327 // When lhs is true, l is the left hand side in a collision.
328 // Both l and m are in the current scope.
329 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#insert().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, m nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#, l *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#, lhs bool) nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node# {
330 switch m := m.(type) {
331 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
332 return l
333 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
334 if m.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k. == l.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k. {
335 left, right := l, m
336 if !lhs {
337 left, right = right, left
338 }
339 return b.collidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#collide().(c, left, right)
340 }
341 return b.joinscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#join().(prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#(l.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.), l, prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#(m.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.), m)
342 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
343 // fallthrough
344 }
345 // m is a branch
346 br := m.(*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#)
347 if !matchPrefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/matchPrefix().(prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#(l.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.), br.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., br.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.) {
348 return b.joinscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#join().(prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#(l.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.), l, br.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., br)
349 }
350 var left, right nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#
351 if zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#(l.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.), br.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.) {
352 left, right = b.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#insert().(c, br.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., l, lhs), br.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.
353 } else {
354 left, right = br.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., b.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#insert().(c, br.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right., l, lhs)
355 }
356 if left == br.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left. && right == br.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right. {
357 return m
358 }
359 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(br.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., br.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching., left, right)
360 }
361
362 // merge two maps in the current scope.
363 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, lhs, rhs nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#) nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node# {
364 if lhs == rhs {
365 return lhs
366 }
367 switch lhs := lhs.(type) {
368 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
369 return rhs
370 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
371 return b.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#insert().(c, rhs, lhs, true)
372 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
373 switch rhs := rhs.(type) {
374 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
375 return lhs
376 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
377 return b.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#insert().(c, lhs, rhs, false)
378 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
379 // fallthrough
380 }
381 }
382
383 // Last remaining case is branch merging.
384 // For brevity, we adopt the Okasaki and Gill naming conventions
385 // for branching and prefixes.
386 s, t := lhs.(*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#), rhs.(*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#)
387 p, m := s.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., s.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.
388 q, n := t.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., t.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.
389
390 if m == n && p == q { // prefixes are identical.
391 left, right := b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, s.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., t.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left.), b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, s.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right., t.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.)
392 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(p, m, left, right)
393 }
394 if !prefixesOverlapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefixesOverlap().(p, m, q, n) {
395 return b.joinscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#join().(p, s, q, t) // prefixes are disjoint.
396 }
397 // prefixesOverlap(p, m, q, n) && !(m ==n && p == q)
398 // By prefixesOverlap(...), either:
399 // higher(m, n) && matchPrefix(q, p, m), or
400 // higher(n, m) && matchPrefix(p, q, n)
401 // So either s or t may can be merged with one branch or the other.
402 switch {
403 case ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/ord().(m, n) && zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(q, m):
404 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(p, m, b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, s.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., t), s.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.)
405 case ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/ord().(m, n) && !zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(q, m):
406 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(p, m, s.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, s.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right., t))
407 case ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/ord().(n, m) && zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(p, n):
408 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(q, n, b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, s, t.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left.), t.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.)
409 default:
410 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(q, n, t.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., b.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#merge().(c, s, t.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.))
411 }
412 }
413
414 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#remove().(m nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#, k keyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/key#) nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node# {
415 switch m := m.(type) {
416 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
417 return m
418 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
419 if m.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k. == k {
420 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
421 }
422 return m
423 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
424 // fallthrough
425 }
426 br := m.(*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#)
427 kp := prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefix#(k)
428 if !matchPrefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/matchPrefix().(kp, br.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., br.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.) {
429 // The prefix does not match. kp is not in br.
430 return br
431 }
432 // the prefix matches. try to remove from the left or right branch.
433 left, right := br.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., br.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.
434 if zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(kp, br.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.) {
435 left = b.removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#remove().(left, k) // k may be in the left branch.
436 } else {
437 right = b.removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#remove().(right, k) // k may be in the right branch.
438 }
439 if left == br.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left. && right == br.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right. {
440 return br // no update
441 } else if _, ok := left.(*emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#); ok {
442 return right // left updated and is empty.
443 } else if _, ok := right.(*emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#); ok {
444 return left // right updated and is empty.
445 }
446 // Either left or right updated. Both left and right are not empty.
447 // The left and right branches still share the same prefix and disagree
448 // on the same branching bit. It is safe to directly create the branch.
449 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(br.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., br.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching., left, right)
450 }
451
452 func (b *Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#) intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#intersect().(c Collisionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Collision#, l, r nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#) nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node# {
453 if l == r {
454 return l
455 }
456 switch l := l.(type) {
457 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
458 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
459 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
460 if rleaf := r.findscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#find.(l.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.); rleaf != nil {
461 return b.collidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#collide().(c, l, rleaf)
462 }
463 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
464 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
465 switch r := r.(type) {
466 case *emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#:
467 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
468 case *leafscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#:
469 if lleaf := l.findscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#find().(r.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/leaf#k.); lleaf != nil {
470 return b.collidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#collide().(c, lleaf, r)
471 }
472 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty.
473 case *branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#:
474 // fallthrough
475 }
476 }
477 // Last remaining case is branch intersection.
478 s, t := l.(*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#), r.(*branchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#)
479 p, m := s.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., s.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.
480 q, n := t.prefixscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#prefix., t.branchingscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#branching.
481
482 if m == n && p == q {
483 // prefixes are identical.
484 left, right := b.intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#intersect().(c, s.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., t.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left.), b.intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#intersect().(c, s.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right., t.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.)
485 if _, ok := left.(*emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#); ok {
486 return right
487 } else if _, ok := right.(*emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/empty#); ok {
488 return left
489 }
490 // The left and right branches are both non-empty.
491 // They still share the same prefix and disagree on the same branching bit.
492 // It is safe to directly create the branch.
493 return b.mkBranchscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#mkBranch().(p, m, left, right)
494 }
495
496 if !prefixesOverlapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/prefixesOverlap().(p, m, q, n) {
497 return b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#empty. // The prefixes share no keys.
498 }
499 // prefixesOverlap(p, m, q, n) && !(m ==n && p == q)
500 // By prefixesOverlap(...), either:
501 // ord(m, n) && matchPrefix(q, p, m), or
502 // ord(n, m) && matchPrefix(p, q, n)
503 // So either s or t may be a strict subtree of the other.
504 var lhs, rhs nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/node#
505 switch {
506 case ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/ord().(m, n) && zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(q, m):
507 lhs, rhs = s.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left., t
508 case ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/ord().(m, n) && !zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(q, m):
509 lhs, rhs = s.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right., t
510 case ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/ord().(n, m) && zeroBitscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/zeroBit().(p, n):
511 lhs, rhs = s, t.leftscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#left.
512 default:
513 lhs, rhs = s, t.rightscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/branch#right.
514 }
515 return b.intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#intersect().(c, lhs, rhs)
516 }