MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / WithFastValuesPrealloc

Function WithFastValuesPrealloc

pkg/util/ctxutil/fast_value.go:74–83  ·  view source on GitHub ↗

WithFastValuesPrealloc is like WithFastValues, but preallocates multiple contexts that can later be reused on subsequent WithFastValue(s) calls to save on allocations.

(parent context.Context)

Source from the content-addressed store, hash-verified

72// contexts that can later be reused on subsequent WithFastValue(s) calls to
73// save on allocations.
74func WithFastValuesPrealloc(parent context.Context) FastValuesBuilder {
75 ancestor, parent := findFastValuesCtxAncestor(parent)
76 container := &fastValuesContainer{}
77 container.used.Store(1)
78 ctx := &container.buf[0]
79 ctx.init(parent, container, ancestor)
80 return FastValuesBuilder{
81 ctx: ctx,
82 }
83}
84
85// FastValuesBuilder contains multiple values; used for WithFastValues.
86type FastValuesBuilder struct {

Callers

nothing calls this directly

Calls 3

initMethod · 0.65
StoreMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…