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

Function splitSize

ext/strings.go:896–901  ·  view source on GitHub ↗

splitSize bounds the size of the parts of a string of size n: at most n + 1 parts of at most n each. Under the aggregate strategy the parts hold at most the string's content plus one unit for each part, an empty string having size 1, so the list's size is at most 2n + 2, which also bounds the defaul

(s cost.QuantityExpr)

Source from the content-addressed store, hash-verified

894// for each part, an empty string having size 1, so the list's size is at most 2n + 2, which also
895// bounds the default strategy's n + 1 parts.
896func splitSize(s cost.QuantityExpr) cost.QuantityExpr {
897 return cost.Min(
898 cost.List(cost.AtMost(cost.Sum(s, cost.Const(1))), cost.AtMost(s)),
899 cost.Sum(cost.Scale(s, 2), cost.Const(2)),
900 )
901}
902
903// stringTransformEvalCost is the EvalCost of the O(n) string transforms: a scan of the receiver
904// and the result's length.

Callers 2

stringSplitCostModelFunction · 0.85
regexExtractAllCostModelFunction · 0.85

Calls 6

MinFunction · 0.92
ListFunction · 0.92
AtMostFunction · 0.92
SumFunction · 0.92
ConstFunction · 0.92
ScaleFunction · 0.92

Tested by

no test coverage detected