this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue: use Vertex.SingleConjunct in Value.Source

Rather than a custom version via LeafConjuncts,
which was also wasteful as it didn't stop after the first conjunct.
The logic is a bit simpler now.

While here, fix up the godoc on Patterns,
which repeated the LookupPath method selector.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I89ef4b053eb11725d5e0ba35eecd76661e8445e2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1225052
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+4 -6
+4 -6
cue/types.go
··· 1000 1000 if v.v == nil { 1001 1001 return nil 1002 1002 } 1003 - count := 0 1003 + c, count := v.v.SingleConjunct() 1004 1004 var src ast.Node 1005 - for c := range v.v.LeafConjuncts() { 1005 + if count == 1 { 1006 1006 src = c.Source() 1007 - count++ 1008 - // TODO(mvdan): break early on count > 1? 1009 1007 } 1010 - if count > 1 || src == nil { 1008 + if src == nil { 1011 1009 src = v.v.Value().Source() 1012 1010 } 1013 1011 return src ··· 2140 2138 // when iterating over struct fields. This includes universal pattern 2141 2139 // constraints such as `[_]: int` or `[=~"^a"]: string` but 2142 2140 // not the ellipsis pattern as selected by [AnyString]: that 2143 - // can be found with [Value.LookupPath].LookupPath(cue.MakePath(cue.AnyString)). 2141 + // can be found with [Value.LookupPath](cue.MakePath(cue.AnyString)). 2144 2142 func Patterns(include bool) Option { 2145 2143 // TODO we can include patterns, but there's no way 2146 2144 // of iterating over patterns _only_ which might be