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)
| 72 | // contexts that can later be reused on subsequent WithFastValue(s) calls to |
| 73 | // save on allocations. |
| 74 | func 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. |
| 86 | type FastValuesBuilder struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…