Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
internal/core/adt: use Closed for checking recursive closedness
Browse files Browse the repository at this point in the history
Prepare for a structure sharing implementation.

Change-Id: I8ede77c9b5301377b47031e70e98d343ef5e3eb6
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9575
Reviewed-by: CUE cueckoo <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
  • Loading branch information
mpvl committed Apr 30, 2021
1 parent 5481b41 commit 3cdf845
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 1 addition & 9 deletions internal/core/adt/closed.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,7 @@ func (v *Vertex) IsInOneOf(t SpanType) bool {
// IsRecursivelyClosed returns true if this value is either a definition or unified
// with a definition.
func (v *Vertex) IsRecursivelyClosed() bool {
if v.IsInOneOf(DefinitionSpan) {
return true
}
for p := v; p != nil; p = p.Parent {
if p.Label.IsDef() {
return true
}
}
return false
return v.Closed || v.IsInOneOf(DefinitionSpan)
}

type closeNodeType uint8
Expand Down
2 changes: 2 additions & 0 deletions internal/core/adt/closed2.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func verifyArc2(ctx *OpContext, f Feature, v *Vertex, isClosed bool) (found bool
// TODO(perf): collect positions in error.
defer ctx.ReleasePositions(ctx.MarkPositions())

// Note: it is okay to use parent here as this only needs to be computed
// for the original location.
if ok, required := Accept(ctx, v.Parent, f); ok || (!required && !isClosed) {
return true, nil
}
Expand Down

0 comments on commit 3cdf845

Please sign in to comment.