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

Function replaceCostTracker

ext/regex.go:440–452  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438}
439
440func replaceCostTracker() interpreter.FunctionTracker {
441 return func(args []ref.Val, result ref.Val) *uint64 {
442 targetCost := float64(actualSize(args[0])+1) * common.StringTraversalCostFactor
443 regexCost := float64(actualSize(args[1])+1) * common.RegexStringLengthCostFactor
444 // Actual search cost calculation = targetCost + regexCost
445 searchCost := targetCost * regexCost
446 // The total cost is the base call cost + search cost + result string allocation.
447 totalCost := float64(callCost) + searchCost + float64(actualSize(result))
448 // Convert to uint64 for the final cost.
449 finalCost := uint64(totalCost)
450 return &finalCost
451 }
452}

Callers 1

ProgramOptionsMethod · 0.85

Calls 1

actualSizeFunction · 0.70

Tested by

no test coverage detected