(types []Type)
| 240 | } |
| 241 | |
| 242 | func (c *Context) LookupTypeUnion(types []Type) *TypeUnion { |
| 243 | sort.SliceStable(types, func(i, j int) bool { |
| 244 | return CompareTypes(types[i], types[j]) < 0 |
| 245 | }) |
| 246 | key := keyPool.Get().(*[]byte) |
| 247 | bytes := (*key)[:0] |
| 248 | for _, typ := range types { |
| 249 | bytes = binary.LittleEndian.AppendUint32(bytes, uint32(TypeID(typ))) |
| 250 | } |
| 251 | *key = bytes |
| 252 | c.mu.Lock() |
| 253 | defer c.mu.Unlock() |
| 254 | if c.unions == nil { |
| 255 | c.unions = make(map[string]*TypeUnion) |
| 256 | } |
| 257 | if typ, ok := c.unions[string(bytes)]; ok { |
| 258 | keyPool.Put(key) |
| 259 | return typ |
| 260 | } |
| 261 | typ := NewTypeUnion(c.nextIDWithLock(), slices.Clone(types)) |
| 262 | c.enterWithLock(typ) |
| 263 | c.unions[string(bytes)] = typ |
| 264 | return typ |
| 265 | } |
| 266 | |
| 267 | func (c *Context) LookupTypeEnum(symbols []string) *TypeEnum { |
| 268 | key := keyPool.Get().(*[]byte) |
no test coverage detected