this repo has no description
0
fork

Configure Feed

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

internal/core: various minor cleanups

compiler.inSelector was never used; remove it.

Make use of range-over-int in the convert package.

Use iterator APIs to simplify toposort.GraphBuilder.Build.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I31038f000080d8a88d0562eb3492c9ee22038f56
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1226972
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>

+5 -12
+1 -4
internal/core/compile/compile.go
··· 106 106 107 107 experiments cueexperiment.File 108 108 109 - stack []frame 110 - inSelector int 109 + stack []frame 111 110 112 111 // refersToForVariable tracks whether an expression refers to a key or 113 112 // value produced by a for comprehension embedded within a struct. ··· 1027 1026 return v 1028 1027 1029 1028 case *ast.SelectorExpr: 1030 - c.inSelector++ 1031 1029 x := c.expr(n.X) 1032 1030 // TODO: check if x is an ImportReference, and if so, check if it a 1033 1031 // standard library, look up the builtin, and check its version. The ··· 1037 1035 Src: n, 1038 1036 X: x, 1039 1037 Sel: c.label(n.Sel)} 1040 - c.inSelector-- 1041 1038 return ret 1042 1039 1043 1040 case *ast.IndexExpr:
+1 -3
internal/core/convert/go.go
··· 481 481 Arcs: make([]*adt.Vertex, 0, numElems), 482 482 } 483 483 484 - i := 0 485 484 // Note that we don't use [reflect.Value.Seq2], 486 485 // as it allocates more per iteration, and we don't need the index value. 487 486 // We can't use [reflect.Value.Seq] either, as that's just the indices. 488 - for i < numElems { 487 + for i := range numElems { 489 488 val := val.Index(i) 490 489 x := fromGoValue(ctx, nilIsTop, val) 491 490 if x == nil { ··· 497 496 list.Elems = append(list.Elems, x) 498 497 f := adt.MakeIntLabel(adt.IntLabel, int64(i)) 499 498 v.Arcs = append(v.Arcs, ensureArcVertex(ctx, x, f)) 500 - i++ 501 499 } 502 500 503 501 env := ctx.Env(0)
+3 -5
internal/core/toposort/graph.go
··· 16 16 17 17 import ( 18 18 "cmp" 19 + "maps" 19 20 "slices" 20 21 21 22 "cuelang.org/go/internal/core/adt" ··· 121 122 } 122 123 123 124 func (builder *GraphBuilder) Build() *Graph { 124 - nodesByFeature := builder.nodesByFeature 125 - nodes := make(Nodes, 0, len(nodesByFeature)) 126 - for _, node := range nodesByFeature { 127 - nodes = append(nodes, node) 128 - } 125 + nodes := make(Nodes, 0, len(builder.nodesByFeature)) 126 + nodes = slices.AppendSeq(nodes, maps.Values(builder.nodesByFeature)) 129 127 return &Graph{nodes: nodes} 130 128 } 131 129