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

Function decOptimize

interpreter/decorators.go:113–130  ·  view source on GitHub ↗

decOptimize optimizes the program plan by looking for common evaluation patterns and conditionally precomputing the result. - build list and map values with constant elements. - convert 'in' operations to set membership tests if possible.

()

Source from the content-addressed store, hash-verified

111// - build list and map values with constant elements.
112// - convert 'in' operations to set membership tests if possible.
113func decOptimize() InterpretableDecoratorV2 {
114 return func(i InterpretableV2) (InterpretableV2, error) {
115 switch inst := i.(type) {
116 case *evalList:
117 return maybeBuildListLiteral(i, inst)
118 case *evalMap:
119 return maybeBuildMapLiteral(i, inst)
120 case InterpretableCall:
121 if inst.OverloadID() == overloads.InList {
122 return maybeOptimizeSetMembership(i, inst)
123 }
124 if overloads.IsTypeConversionFunction(inst.Function()) {
125 return maybeOptimizeConstUnary(i, inst)
126 }
127 }
128 return i, nil
129 }
130}
131
132// decRegexOptimizer compiles regex pattern string constants.
133func decRegexOptimizer(regexOptimizations ...*RegexOptimization) InterpretableDecoratorV2 {

Callers 1

OptimizeFunction · 0.85

Calls 7

IsTypeConversionFunctionFunction · 0.92
maybeBuildListLiteralFunction · 0.85
maybeBuildMapLiteralFunction · 0.85
maybeOptimizeConstUnaryFunction · 0.85
OverloadIDMethod · 0.65
FunctionMethod · 0.65

Tested by

no test coverage detected