Skip to content

Commit 98a3f93

Browse files
committed
internal/core/adt: do not add arc dependencies for some nodes
Let and root nodes can never depend on their parent, and as such, we should not add the dependency. This is currently a no-op, but not doing so will break once we implement the reduction of closeContext graph depth optimization. Issue #2850 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I6ddc07278a7a489a19b8f7237128655cb87c69bb Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1209180 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
1 parent 58b3e7d commit 98a3f93

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

cue/testdata/cycle/issue990.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Allocs: 1265
8787
Retain: 0
8888

8989
Unifications: 243
90-
Conjuncts: 4276
90+
Conjuncts: 4197
9191
Disjuncts: 204
9292
-- out/evalalpha --
9393
(struct){
@@ -338,7 +338,7 @@ diff old new
338338
-Conjuncts: 12056
339339
-Disjuncts: 3258
340340
+Unifications: 243
341-
+Conjuncts: 4276
341+
+Conjuncts: 4197
342342
+Disjuncts: 204
343343
-- diff/-out/evalalpha<==>+out/eval --
344344
diff old new

cue/testdata/eval/letjoin.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Allocs: 222
139139
Retain: 0
140140

141141
Unifications: 178
142-
Conjuncts: 1209
142+
Conjuncts: 1205
143143
Disjuncts: 36
144144
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
145145
diff old new
@@ -161,7 +161,7 @@ diff old new
161161
-Conjuncts: 486
162162
-Disjuncts: 325
163163
+Unifications: 178
164-
+Conjuncts: 1209
164+
+Conjuncts: 1205
165165
+Disjuncts: 36
166166
-- out/eval/stats --
167167
Leaks: 24

internal/core/adt/composite.go

+4
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ func (v *Vertex) rootCloseContext(ctx *OpContext) *closeContext {
335335
}
336336
v._cc.incDependent(ctx, ROOT, nil) // matched in REF(decrement:nodeDone)
337337

338+
if f := v.Label; f.IsLet() || f == InvalidLabel {
339+
return v._cc
340+
}
341+
338342
if p := v.Parent; p != nil {
339343
pcc := p.rootCloseContext(ctx)
340344
// pcc.addDependency(ctx, ARC, false, v._cc, v._cc, v._cc)

internal/core/adt/dep.go

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ type ccDepRef struct {
147147

148148
// addArc adds a dependent arc to c. If child is an arc, child.src == key
149149
func (c *closeContext) addArcDependency(ctx *OpContext, matched bool, child *closeContext) {
150+
if f := child.src.Label; f.IsLet() || f == InvalidLabel {
151+
return
152+
}
153+
150154
root := child.src.cc()
151155

152156
// NOTE: do not increment

0 commit comments

Comments
 (0)