MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / IsFunctionOverload

Function IsFunctionOverload

eval/compiler/regex_precompilation_optimization.cc:62–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60using ReferenceMap = absl::flat_hash_map<int64_t, Reference>;
61
62bool IsFunctionOverload(const Expr& expr, absl::string_view function,
63 absl::string_view overload, size_t arity,
64 const ReferenceMap& reference_map) {
65 if (!expr.has_call_expr()) {
66 return false;
67 }
68 const auto& call_expr = expr.call_expr();
69 if (call_expr.function() != function) {
70 return false;
71 }
72 if (call_expr.args().size() + (call_expr.has_target() ? 1 : 0) != arity) {
73 return false;
74 }
75
76 // If parse-only and opted in to the optimization, assume this is the intended
77 // overload. This will still only change the evaluation plan if the second arg
78 // is a constant string.
79 if (reference_map.empty()) {
80 return true;
81 }
82
83 auto reference = reference_map.find(expr.id());
84 if (reference != reference_map.end() &&
85 reference->second.overload_id().size() == 1 &&
86 reference->second.overload_id().front() == overload) {
87 return true;
88 }
89 return false;
90}
91
92// Abstraction for deduplicating regular expressions over the course of a single
93// create expression call. Should not be used during evaluation. Uses

Callers 1

OnPostVisitMethod · 0.85

Calls 7

has_call_exprMethod · 0.80
argsMethod · 0.80
has_targetMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
idMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected