listJoinStringCostModel models l.join(delim): it reads the list once and builds the result with delimiters between elements.
(id string)
| 977 | // listJoinStringCostModel models l.join(delim): it reads the list once and builds the result with |
| 978 | // delimiters between elements. |
| 979 | func listJoinStringCostModel(id string) cost.OverloadModel { |
| 980 | return cost.MemberOverload(id, |
| 981 | cost.EvalCost(cost.Sum(cost.Const(cost.CallCost), cost.StringScan(cost.Sum(cost.Length(cost.Target()), cost.Const(1))), cost.Length(cost.Result()))), |
| 982 | cost.ResultSize(cost.AtMost(cost.Sum( |
| 983 | cost.ElemTotal(cost.Target()), |
| 984 | cost.Mul(cost.Length(cost.Target()), cost.Arg(0)), |
| 985 | ))), |
| 986 | cost.BeforeVersion(1, cost.ResultSize(cost.AtMost(cost.Sum( |
| 987 | cost.Mul(cost.Length(cost.Target()), cost.Sum(cost.Const(1), cost.Arg(0))), |
| 988 | cost.Arg(0), |
| 989 | )))), |
| 990 | ) |
| 991 | } |
| 992 | |
| 993 | // stringReplaceCostModel models replace: it searches the receiver for the needle and builds the |
| 994 | // result. Without a match the result is the receiver, and with one it contains the replacement, so |
no test coverage detected