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

Function newFastValuesCtx

pkg/util/ctxutil/fast_value.go:168–185  ·  view source on GitHub ↗

newFastValuesCtx returns a new context with the given parent and the values from the ancestor. If the ancestor has an associated container that has free slots, it is used to avoid a new allocation.

(ancestor *fastValuesCtx, parent context.Context)

Source from the content-addressed store, hash-verified

166// If the ancestor has an associated container that has free slots, it is used
167// to avoid a new allocation.
168func newFastValuesCtx(ancestor *fastValuesCtx, parent context.Context) *fastValuesCtx {
169 var ctx *fastValuesCtx
170 var container *fastValuesContainer
171 if ancestor != nil && ancestor.container != nil {
172 // Try to use the container.
173 var more bool
174 ctx, more = ancestor.container.get()
175 if more {
176 container = ancestor.container
177 } else if ctx == nil {
178 ctx = &fastValuesCtx{}
179 }
180 } else {
181 ctx = &fastValuesCtx{}
182 }
183 ctx.init(parent, container, ancestor)
184 return ctx
185}
186
187// findFastValuesCtxAncestor returns the closest fastValuesCtx ancestor of the
188// given parent context.

Callers 2

WithFastValueFunction · 0.85
WithFastValuesFunction · 0.85

Calls 2

initMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…