this repo has no description
0
fork

Configure Feed

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

internal/core/convert: reuse singleton struct and list marker allocs

These are empty struct types, so there is no need to create
new ones for each value.

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

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

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

+8 -2
+8 -2
internal/core/convert/go.go
··· 451 451 } 452 452 453 453 v.AddStruct(obj) 454 - v.SetValue(ctx, &adt.StructMarker{}) 454 + v.SetValue(ctx, structMarker) 455 455 v.ForceDone() 456 456 return v 457 457 ··· 492 492 } 493 493 494 494 v.AddConjunct(adt.MakeRootConjunct(env, list)) 495 - v.SetValue(ctx, &adt.ListMarker{}) 495 + v.SetValue(ctx, listMarker) 496 496 v.ForceDone() 497 497 return v 498 498 } 499 499 return nil 500 500 } 501 + 502 + // These are effectively singletons, so avoid allocating new ones. 503 + var ( 504 + structMarker = &adt.StructMarker{} 505 + listMarker = &adt.ListMarker{} 506 + ) 501 507 502 508 func fromGoBigInt(x *big.Int) apd.Decimal { 503 509 // Integers fitting in 64 bits is rather common.