(e ast.Expr)
| 621 | } |
| 622 | |
| 623 | func (c *coster) costCreateMap(e ast.Expr) CostEstimate { |
| 624 | mapVal := e.AsMap() |
| 625 | var sum CostEstimate |
| 626 | keySize := SizeEstimate{Min: math.MaxUint64, Max: 0} |
| 627 | valSize := SizeEstimate{Min: math.MaxUint64, Max: 0} |
| 628 | if mapVal.Size() == 0 { |
| 629 | valSize.Min = 0 |
| 630 | keySize.Min = 0 |
| 631 | } |
| 632 | for _, ent := range mapVal.Entries() { |
| 633 | entry := ent.AsMapEntry() |
| 634 | sum = sum.Add(c.cost(entry.Key())) |
| 635 | sum = sum.Add(c.cost(entry.Value())) |
| 636 | // Compute the key size range |
| 637 | ks := c.sizeOrUnknown(entry.Key()) |
| 638 | keySize = keySize.Union(ks) |
| 639 | // Compute the value size range |
| 640 | vs := c.sizeOrUnknown(entry.Value()) |
| 641 | valSize = valSize.Union(vs) |
| 642 | } |
| 643 | c.setEntrySize(e, &entrySizeEstimate{containerKind: types.MapKind, key: keySize, val: valSize}) |
| 644 | return sum.Add(createMapBaseCost) |
| 645 | } |
| 646 | |
| 647 | func (c *coster) costCreateStruct(e ast.Expr) CostEstimate { |
| 648 | msgVal := e.AsStruct() |
no test coverage detected