(keyType, valType Type)
| 219 | } |
| 220 | |
| 221 | func (c *Context) LookupTypeMap(keyType, valType Type) *TypeMap { |
| 222 | key := keyPool.Get().(*[]byte) |
| 223 | bytes := (*key)[:0] |
| 224 | bytes = binary.LittleEndian.AppendUint32(bytes, uint32(TypeID(keyType))) |
| 225 | bytes = binary.LittleEndian.AppendUint32(bytes, uint32(TypeID(valType))) |
| 226 | *key = bytes |
| 227 | c.mu.Lock() |
| 228 | defer c.mu.Unlock() |
| 229 | if c.maps == nil { |
| 230 | c.maps = make(map[string]*TypeMap) |
| 231 | } |
| 232 | if typ, ok := c.maps[string(bytes)]; ok { |
| 233 | keyPool.Put(key) |
| 234 | return typ |
| 235 | } |
| 236 | typ := NewTypeMap(c.nextIDWithLock(), keyType, valType) |
| 237 | c.enterWithLock(typ) |
| 238 | c.maps[string(bytes)] = typ |
| 239 | return typ |
| 240 | } |
| 241 | |
| 242 | func (c *Context) LookupTypeUnion(types []Type) *TypeUnion { |
| 243 | sort.SliceStable(types, func(i, j int) bool { |
no test coverage detected