this repo has no description
0
fork

Configure Feed

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

internal/core/convert: allocate vertices in ensureArcVertex better

Allocate once rather than twice in the helper.
The use of a one-element array rather than using append
also avoids extra capacity in the slice, which is wasted space.

│ old │ new │
│ B/op │ B/op vs base │
VetInventory 4.613Gi ± ∞ ¹ 4.602Gi ± ∞ ¹ -0.23% (p=1.000 n=1)

│ old │ new │
│ allocs/op │ allocs/op vs base │
VetInventory 49.06M ± ∞ ¹ 48.33M ± ∞ ¹ -1.50% (p=1.000 n=1)

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ia1cb03bc80e85603d4525188369dfeedb69f86fb
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229434
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+10 -1
+10 -1
internal/core/convert/go.go
··· 527 527 a.Label = l 528 528 return &a 529 529 } 530 - arc := &adt.Vertex{Label: l} 530 + // We know this is one vertex with exactly one conjunct, 531 + // so allocate both together to reduce the runtime overhead. 532 + var alloc struct { 533 + arc adt.Vertex 534 + conjs [1]adt.Conjunct 535 + } 536 + arc := &alloc.arc 537 + arc.Conjuncts = alloc.conjs[:0] 538 + 539 + arc.Label = l 531 540 arc.AddConjunct(adt.MakeRootConjunct(env, x)) 532 541 arc.SetValue(ctx, x) 533 542 arc.ForceDone()