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

Function stringSubstringCostModel

ext/strings.go:942–951  ·  view source on GitHub ↗

stringSubstringCostModel models s.substring(start): it drops at least start units of the receiver, and at most 4 times as many under the aggregate strategy (where each code point takes 1 to 4 UTF-8 bytes).

(id string)

Source from the content-addressed store, hash-verified

940// receiver, and at most 4 times as many under the aggregate strategy (where each code point takes
941// 1 to 4 UTF-8 bytes).
942func stringSubstringCostModel(id string) cost.OverloadModel {
943 return cost.MemberOverload(id,
944 stringTransformEvalCost(),
945 cost.ResultSize(cost.Ranged(
946 cost.Sub(cost.Target(), cost.Scale(cost.IntArg(0, 0), 4)),
947 cost.Sub(cost.Target(), cost.IntArg(0, 0)),
948 )),
949 cost.BeforeVersion(1, cost.ManualEstimator(estimateSubstringCost)),
950 )
951}
952
953// stringSubstringRangeCostModel models s.substring(start, end): the result has end - start code
954// points, sized between that length and 4 times it under the aggregate strategy, and never above

Callers 1

CompileOptionsMethod · 0.85

Calls 10

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

Tested by

no test coverage detected