Skip to content

Commit fb4f507

Browse files
committed
internal/core/adt: clean up use of Vertex.state
This is to make it easier to see that this field is used when it is non-nil. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I2225ecc55a398b8b978ead8297a63376bca04a2a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1218220 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 4ebd05f commit fb4f507

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

internal/core/adt/context.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,14 +724,12 @@ func (c *OpContext) evalStateCI(v Expr, state combinedFlags) (result Value, ci C
724724
// TODO: is this indirect necessary?
725725
// arc = arc.Indirect()
726726

727-
n := arc.state
728727
if c.isDevVersion() {
729-
n = arc.getState(c)
730-
if n != nil {
728+
if n := arc.getState(c); n != nil {
731729
c.ci, _ = n.detectCycleV3(arc, nil, x, c.ci)
732730
}
733731
} else {
734-
if n != nil {
732+
if n := arc.state; n != nil {
735733
c.ci, _ = n.markCycle(arc, nil, x, c.ci)
736734
}
737735
}
@@ -742,7 +740,7 @@ func (c *OpContext) evalStateCI(v Expr, state combinedFlags) (result Value, ci C
742740

743741
if c.isDevVersion() {
744742
if s := arc.getState(c); s != nil {
745-
defer n.retainProcess().releaseProcess()
743+
defer s.retainProcess().releaseProcess()
746744

747745
origNeeds := state.conditions()
748746
needs := origNeeds | arcTypeKnown
@@ -751,7 +749,7 @@ func (c *OpContext) evalStateCI(v Expr, state combinedFlags) (result Value, ci C
751749
switch runMode {
752750
case finalize:
753751
arc.unify(c, needs, attemptOnly, true) // to set scalar
754-
arc.state.freeze(needs)
752+
s.freeze(needs)
755753
case attemptOnly:
756754
arc.unify(c, needs, attemptOnly, true) // to set scalar
757755

internal/core/adt/cycle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ func (n *nodeContext) detectCycleV3(arc *Vertex, env *Environment, x Resolver, c
684684
// c: a: int
685685
//
686686
// This is equivalent to a reference cycle.
687-
if r.Depth == n.node.state.depth {
687+
if r.Depth == n.depth {
688688
return ci, true
689689
}
690690
ci.Refs = nil

0 commit comments

Comments
 (0)