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

Function trackStringSearchCost

ext/strings.go:1047–1051  ·  view source on GitHub ↗

trackStringSearchCost tracks runtime cost for O(n*m) string search operations.

(args []ref.Val, _ ref.Val)

Source from the content-addressed store, hash-verified

1045
1046// trackStringSearchCost tracks runtime cost for O(n*m) string search operations.
1047func trackStringSearchCost(args []ref.Val, _ ref.Val) *uint64 {
1048 searchCost := float64(actualSize(args[0])*actualSize(args[1])) * stringCostFactor
1049 cost := safeAdd(uint64(math.Ceil(searchCost)), callCost)
1050 return &cost
1051}
1052
1053// trackStringReplaceCost tracks runtime cost for string replace operations,
1054// accounting for search cost and the size of the result.

Callers

nothing calls this directly

Calls 2

safeAddFunction · 0.85
actualSizeFunction · 0.70

Tested by

no test coverage detected