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

Method costSelect

checker/cost.go:507–529  ·  view source on GitHub ↗
(e ast.Expr)

Source from the content-addressed store, hash-verified

505}
506
507func (c *coster) costSelect(e ast.Expr) CostEstimate {
508 sel := e.AsSelect()
509 var sum CostEstimate
510 if sel.IsTestOnly() {
511 // recurse, but do not add any cost
512 // this is equivalent to how evalTestOnly increments the runtime cost counter
513 // but does not add any additional cost for the qualifier, except here we do
514 // the reverse (ident adds cost)
515 sum = sum.Add(c.presenceTestCost)
516 sum = sum.Add(c.cost(sel.Operand()))
517 return sum
518 }
519 sum = sum.Add(c.cost(sel.Operand()))
520 targetType := c.getType(sel.Operand())
521 switch targetType.Kind() {
522 case types.MapKind, types.StructKind, types.TypeParamKind:
523 sum = sum.Add(selectAndIdentCost)
524 }
525
526 // build and track the field path
527 c.addPath(e, append(c.getPath(sel.Operand()), sel.FieldName()))
528 return sum
529}
530
531func (c *coster) costCall(e ast.Expr) CostEstimate {
532 // Dyn is just a way to disable type-checking, so return the cost of 1 with the cost of the argument

Callers 1

costMethod · 0.95

Calls 10

AddMethod · 0.95
costMethod · 0.95
getTypeMethod · 0.95
addPathMethod · 0.95
getPathMethod · 0.95
AsSelectMethod · 0.65
IsTestOnlyMethod · 0.65
OperandMethod · 0.65
KindMethod · 0.65
FieldNameMethod · 0.65

Tested by

no test coverage detected