| 60 | using ReferenceMap = absl::flat_hash_map<int64_t, Reference>; |
| 61 | |
| 62 | bool 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 |
no test coverage detected