regexExtractCostModel models regex.extract: it searches the target, and returns an optional holding the first match or capture group, a part of the target. The result is charged as the optional it is, 1 plus the size of the part (1 when nothing matched); see cost.Optional. Version 0 sizes an optiona
(id string)
| 402 | // optional it is, 1 plus the size of the part (1 when nothing matched); see cost.Optional. Version 0 |
| 403 | // sizes an optional as 1, which is what v0.32.0 charged. |
| 404 | func regexExtractCostModel(id string) cost.OverloadModel { |
| 405 | return cost.Overload(id, |
| 406 | cost.EvalCost(cost.Sum(cost.Const(cost.CallCost), regexSearch(cost.Arg(0), cost.Arg(1)), cost.Result())), |
| 407 | cost.ResultSize(cost.Optional(cost.AtMost(cost.Arg(0)))), |
| 408 | cost.BeforeVersion(1, cost.ManualEstimator(estimateExtractCost)), |
| 409 | ) |
| 410 | } |
| 411 | |
| 412 | // regexExtractAllCostModel models regex.extractAll: it returns parts of the target, sized as the |
| 413 | // parts of a split. |
no test coverage detected