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

Function listJoinStringCostModel

ext/strings.go:979–991  ·  view source on GitHub ↗

listJoinStringCostModel models l.join(delim): it reads the list once and builds the result with delimiters between elements.

(id string)

Source from the content-addressed store, hash-verified

977// listJoinStringCostModel models l.join(delim): it reads the list once and builds the result with
978// delimiters between elements.
979func listJoinStringCostModel(id string) cost.OverloadModel {
980 return cost.MemberOverload(id,
981 cost.EvalCost(cost.Sum(cost.Const(cost.CallCost), cost.StringScan(cost.Sum(cost.Length(cost.Target()), cost.Const(1))), cost.Length(cost.Result()))),
982 cost.ResultSize(cost.AtMost(cost.Sum(
983 cost.ElemTotal(cost.Target()),
984 cost.Mul(cost.Length(cost.Target()), cost.Arg(0)),
985 ))),
986 cost.BeforeVersion(1, cost.ResultSize(cost.AtMost(cost.Sum(
987 cost.Mul(cost.Length(cost.Target()), cost.Sum(cost.Const(1), cost.Arg(0))),
988 cost.Arg(0),
989 )))),
990 )
991}
992
993// stringReplaceCostModel models replace: it searches the receiver for the needle and builds the
994// result. Without a match the result is the receiver, and with one it contains the replacement, so

Callers 1

CompileOptionsMethod · 0.85

Calls 14

MemberOverloadFunction · 0.92
EvalCostFunction · 0.92
SumFunction · 0.92
ConstFunction · 0.92
StringScanFunction · 0.92
LengthFunction · 0.92
TargetFunction · 0.92
ResultFunction · 0.92
ResultSizeFunction · 0.92
AtMostFunction · 0.92
ElemTotalFunction · 0.92
MulFunction · 0.92

Tested by

no test coverage detected