initialized lazily insert attempts to insert an object obj into objset s. If s already contains an alternative object alt with the same name, insert leaves s unchanged and returns alt. Otherwise it inserts obj and returns nil.
(obj Object)
| 19 | // the same name, insert leaves s unchanged and returns alt. |
| 20 | // Otherwise it inserts obj and returns nil. |
| 21 | func (s *objset) insert(obj Object) Object { |
| 22 | id := obj.Id() |
| 23 | if alt := (*s)[id]; alt != nil { |
| 24 | return alt |
| 25 | } |
| 26 | if *s == nil { |
| 27 | *s = make(map[string]Object) |
| 28 | } |
| 29 | (*s)[id] = obj |
| 30 | return nil |
| 31 | } |
no test coverage detected