MCPcopy Create free account
hub / github.com/cel-expr/cel-go / estimateStringCharAtCost

Function estimateStringCharAtCost

ext/strings.go:924–931  ·  view source on GitHub ↗

estimateStringCharAtCost includes a cost of 1 for the allocation, plus the string traversal cost.

(estimator checker.CostEstimator, target *checker.AstNode, args []checker.AstNode)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

estimateStringScanFunction · 0.85
rangedSizeEstimateFunction · 0.85
callEstimateFunction · 0.85
estimateSizeFunction · 0.70
AddMethod · 0.65

Tested by

no test coverage detected