splitSize bounds the size of the parts of a string of size n: at most n + 1 parts of at most n each. Under the aggregate strategy the parts hold at most the string's content plus one unit for each part, an empty string having size 1, so the list's size is at most 2n + 2, which also bounds the defaul
(s cost.QuantityExpr)
| 894 | // for each part, an empty string having size 1, so the list's size is at most 2n + 2, which also |
| 895 | // bounds the default strategy's n + 1 parts. |
| 896 | func splitSize(s cost.QuantityExpr) cost.QuantityExpr { |
| 897 | return cost.Min( |
| 898 | cost.List(cost.AtMost(cost.Sum(s, cost.Const(1))), cost.AtMost(s)), |
| 899 | cost.Sum(cost.Scale(s, 2), cost.Const(2)), |
| 900 | ) |
| 901 | } |
| 902 | |
| 903 | // stringTransformEvalCost is the EvalCost of the O(n) string transforms: a scan of the receiver |
| 904 | // and the result's length. |