MCPcopy Index your code
hub / github.com/jetify-com/devbox / getOrAppend

Method getOrAppend

internal/shellgen/flake_input.go:207–217  ·  view source on GitHub ↗

getOrAppend returns a pointer to the slice element with a given key. If the key doesn't exist, a new element is automatically appended to the slice. The pointer is valid until the next append.

(key string)

Source from the content-addressed store, hash-verified

205// key doesn't exist, a new element is automatically appended to the slice. The
206// pointer is valid until the next append.
207func (k *keyedSlice) getOrAppend(key string) *flakeInput {
208 if k.lookup == nil {
209 k.lookup = make(map[string]int)
210 }
211 if i, ok := k.lookup[key]; ok {
212 return &k.slice[i]
213 }
214 k.slice = append(k.slice, flakeInput{})
215 k.lookup[key] = len(k.slice) - 1
216 return &k.slice[len(k.slice)-1]
217}
218
219// needsSymlinkJoin is used to filter packages with multiple outputs.
220// Multiple outputs -> SymlinkJoin.

Callers 1

flakeInputsFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected