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

Function estimateStringCharAtCost

ext/strings.go:923–930  ·  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

921
922// estimateStringCharAtCost includes a cost of 1 for the allocation, plus the string traversal cost.
923func 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.
933func 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