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

Method computeSize

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

Source from the content-addressed store, hash-verified

941}
942
943func (c *coster) computeSize(e ast.Expr) *SizeEstimate {
944 if size, ok := c.computedSizes[e.ID()]; ok {
945 return &size
946 }
947 if size := computeExprSize(e); size != nil {
948 return size
949 }
950 // Ensure size estimates are computed first as users may choose to override the costs that
951 // CEL would otherwise ascribe to the type.
952 node := astNode{expr: e, path: c.getPath(e), t: c.getType(e)}
953 if size := c.estimator.EstimateSize(node); size != nil {
954 // storing the computed size should reduce calls to EstimateSize()
955 c.computedSizes[e.ID()] = *size
956 return size
957 }
958 if size := computeTypeSize(c.getType(e)); size != nil {
959 return size
960 }
961 if e.Kind() == ast.IdentKind {
962 varName := e.AsIdent()
963 if v, ok := c.peekLocalVar(varName); ok && v.size != nil {
964 return v.size
965 }
966 }
967 return nil
968}
969
970func (c *coster) setEntrySize(e ast.Expr, size *entrySizeEstimate) {
971 if size == nil {

Callers 6

pushLocalVarMethod · 0.95
costCallMethod · 0.95
costComprehensionMethod · 0.95
newAstNodeMethod · 0.95
sizeOrUnknownMethod · 0.95
copySizeEstimatesMethod · 0.95

Calls 9

getPathMethod · 0.95
getTypeMethod · 0.95
peekLocalVarMethod · 0.95
computeExprSizeFunction · 0.85
computeTypeSizeFunction · 0.85
IDMethod · 0.65
EstimateSizeMethod · 0.65
KindMethod · 0.65
AsIdentMethod · 0.65

Tested by

no test coverage detected