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

Function stringSubstringRangeCostModel

ext/strings.go:956–966  ·  view source on GitHub ↗

stringSubstringRangeCostModel models s.substring(start, end): the result has end - start code points, sized between that length and 4 times it under the aggregate strategy, and never above the remaining suffix of the receiver.

(id string)

Source from the content-addressed store, hash-verified

954// points, sized between that length and 4 times it under the aggregate strategy, and never above
955// the remaining suffix of the receiver.
956func stringSubstringRangeCostModel(id string) cost.OverloadModel {
957 length := cost.Sub(cost.IntArg(1, 0), cost.IntArg(0, 0))
958 return cost.MemberOverload(id,
959 stringTransformEvalCost(),
960 cost.ResultSize(cost.Ranged(
961 length,
962 cost.Min(cost.Sub(cost.Target(), cost.IntArg(0, 0)), cost.Scale(length, 4)),
963 )),
964 cost.BeforeVersion(1, cost.ManualEstimator(estimateSubstringCost)),
965 )
966}
967
968// listJoinCostModel models l.join(): it reads the list once and builds the concatenated result.
969func listJoinCostModel(id string) cost.OverloadModel {

Callers 1

CompileOptionsMethod · 0.85

Calls 11

SubFunction · 0.92
IntArgFunction · 0.92
MemberOverloadFunction · 0.92
ResultSizeFunction · 0.92
RangedFunction · 0.92
MinFunction · 0.92
TargetFunction · 0.92
ScaleFunction · 0.92
BeforeVersionFunction · 0.92
ManualEstimatorFunction · 0.92
stringTransformEvalCostFunction · 0.85

Tested by

no test coverage detected