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)
| 205 | // key doesn't exist, a new element is automatically appended to the slice. The |
| 206 | // pointer is valid until the next append. |
| 207 | func (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. |