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

Function stringCharAtCostModel

ext/strings.go:911–917  ·  view source on GitHub ↗

stringCharAtCostModel models charAt: it scans the receiver and returns a single code point, which is at most 4 UTF-8 bytes under the aggregate strategy and never above the receiver's size.

(id string)

Source from the content-addressed store, hash-verified

909// stringCharAtCostModel models charAt: it scans the receiver and returns a single code point, which
910// is at most 4 UTF-8 bytes under the aggregate strategy and never above the receiver's size.
911func stringCharAtCostModel(id string) cost.OverloadModel {
912 return cost.MemberOverload(id,
913 cost.EvalCost(cost.Sum(cost.Const(cost.CallCost+1), cost.StringScan(cost.Length(cost.Target())))),
914 cost.ResultSize(cost.AtMost(cost.Min(cost.Target(), cost.Const(4)))),
915 cost.BeforeVersion(1, cost.ResultSize(cost.AtMost(cost.Const(1)))),
916 )
917}
918
919func stringSearchCostModel(id string) cost.OverloadModel {
920 return cost.MemberOverload(id,

Callers 1

CompileOptionsMethod · 0.85

Calls 11

MemberOverloadFunction · 0.92
EvalCostFunction · 0.92
SumFunction · 0.92
ConstFunction · 0.92
StringScanFunction · 0.92
LengthFunction · 0.92
TargetFunction · 0.92
ResultSizeFunction · 0.92
AtMostFunction · 0.92
MinFunction · 0.92
BeforeVersionFunction · 0.92

Tested by

no test coverage detected