(e ast.Expr)
| 591 | } |
| 592 | |
| 593 | func (c *coster) costCreateMap(e ast.Expr) CostEstimate { |
| 594 | mapVal := e.AsMap() |
| 595 | var sum CostEstimate |
| 596 | keySize := SizeEstimate{Min: math.MaxUint64, Max: 0} |
| 597 | valSize := SizeEstimate{Min: math.MaxUint64, Max: 0} |
| 598 | if mapVal.Size() == 0 { |
| 599 | valSize.Min = 0 |
| 600 | keySize.Min = 0 |
| 601 | } |
| 602 | for _, ent := range mapVal.Entries() { |
| 603 | entry := ent.AsMapEntry() |
| 604 | sum = sum.Add(c.cost(entry.Key())) |
| 605 | sum = sum.Add(c.cost(entry.Value())) |
| 606 | // Compute the key size range |
| 607 | ks := c.sizeOrUnknown(entry.Key()) |
| 608 | keySize = keySize.Union(ks) |
| 609 | // Compute the value size range |
| 610 | vs := c.sizeOrUnknown(entry.Value()) |
| 611 | valSize = valSize.Union(vs) |
| 612 | } |
| 613 | c.setEntrySize(e, &entrySizeEstimate{containerKind: types.MapKind, key: keySize, val: valSize}) |
| 614 | return sum.Add(createMapBaseCost) |
| 615 | } |
| 616 | |
| 617 | func (c *coster) costCreateStruct(e ast.Expr) CostEstimate { |
| 618 | msgVal := e.AsStruct() |
no test coverage detected