estimateStringCharAtCost includes a cost of 1 for the allocation, plus the string traversal cost.
(estimator checker.CostEstimator, target *checker.AstNode, args []checker.AstNode)
| 921 | |
| 922 | // estimateStringCharAtCost includes a cost of 1 for the allocation, plus the string traversal cost. |
| 923 | func estimateStringCharAtCost(estimator checker.CostEstimator, target *checker.AstNode, args []checker.AstNode) *checker.CallEstimate { |
| 924 | if target == nil || len(args) != 1 { |
| 925 | return nil |
| 926 | } |
| 927 | cost, _ := estimateStringScan(estimateSize(estimator, *target)) |
| 928 | resultSize := rangedSizeEstimate(0, 1) |
| 929 | return callEstimate(cost.Add(callCostEstimate).Add(callCostEstimate), &resultSize) |
| 930 | } |
| 931 | |
| 932 | // estimateSubstringCost estimates the cost for an O(n) traversal and allocation. |
| 933 | func estimateSubstringCost(estimator checker.CostEstimator, target *checker.AstNode, args []checker.AstNode) *checker.CallEstimate { |
nothing calls this directly
no test coverage detected