From 2ecdb219fb8633c7fd7b92ec9d286d15de73da16 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 12 Jun 2022 13:49:17 +0300 Subject: [PATCH] cql3: expr: make evaluate() static They aren't called from anywhere outside expression.cc, and we're playing with the signatures, so hide them to avoid rebuilds. --- cql3/expr/expression.cc | 16 +++++++++++----- cql3/expr/expression.hh | 5 ----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cql3/expr/expression.cc b/cql3/expr/expression.cc index e9f8699362..047c5c50ea 100644 --- a/cql3/expr/expression.cc +++ b/cql3/expr/expression.cc @@ -84,6 +84,12 @@ binary_operator::binary_operator(expression lhs, oper_t op, expression rhs, comp // Since column_identifier_raw is forward-declared in expression.hh, delay destructor instantiation here unresolved_identifier::~unresolved_identifier() = default; +static constant evaluate(const bind_variable&, const query_options&); +static constant evaluate(const tuple_constructor&, const query_options&); +static constant evaluate(const collection_constructor&, const query_options&); +static constant evaluate(const usertype_constructor&, const query_options&); +static constant evaluate(const function_call&, const query_options&); + namespace { using children_t = std::vector; // conjunction's children. @@ -1843,7 +1849,7 @@ static managed_bytes reserialize_value(View value_bytes, fmt::format("Reserializing type that shouldn't need reserialization: {}", type.name())); } -constant evaluate(const bind_variable& bind_var, const query_options& options) { +static constant evaluate(const bind_variable& bind_var, const query_options& options) { if (bind_var.receiver.get() == nullptr) { on_internal_error(expr_logger, "evaluate(bind_variable) called with nullptr receiver, should be prepared first"); @@ -1878,7 +1884,7 @@ constant evaluate(const bind_variable& bind_var, const query_options& options) { return constant(raw_value::make_value(value), bind_var.receiver->type); } -constant evaluate(const tuple_constructor& tuple, const query_options& options) { +static constant evaluate(const tuple_constructor& tuple, const query_options& options) { if (tuple.type.get() == nullptr) { on_internal_error(expr_logger, "evaluate(tuple_constructor) called with nullptr type, should be prepared first"); @@ -2031,7 +2037,7 @@ static constant evaluate_map(const collection_constructor& collection, const que return constant(raw_value::make_value(std::move(serialized_map)), collection.type); } -constant evaluate(const collection_constructor& collection, const query_options& options) { +static constant evaluate(const collection_constructor& collection, const query_options& options) { if (collection.type.get() == nullptr) { on_internal_error(expr_logger, "evaluate(collection_constructor) called with nullptr type, should be prepared first"); @@ -2050,7 +2056,7 @@ constant evaluate(const collection_constructor& collection, const query_options& std::abort(); } -constant evaluate(const usertype_constructor& user_val, const query_options& options) { +static constant evaluate(const usertype_constructor& user_val, const query_options& options) { if (user_val.type.get() == nullptr) { on_internal_error(expr_logger, "evaluate(usertype_constructor) called with nullptr type, should be prepared first"); @@ -2088,7 +2094,7 @@ constant evaluate(const usertype_constructor& user_val, const query_options& opt return constant(std::move(val_bytes), std::move(user_val.type)); } -constant evaluate(const function_call& fun_call, const query_options& options) { +static constant evaluate(const function_call& fun_call, const query_options& options) { const shared_ptr* fun = std::get_if>(&fun_call.func); if (fun == nullptr) { throw std::runtime_error("Can't evaluate function call with name only, should be prepared earlier"); diff --git a/cql3/expr/expression.hh b/cql3/expr/expression.hh index 9c2b2d026c..bfea6fe829 100644 --- a/cql3/expr/expression.hh +++ b/cql3/expr/expression.hh @@ -674,11 +674,6 @@ data_type type_of(const expression& e); // Takes a prepared expression and calculates its value. // Evaluates bound values, calls functions and returns just the bytes and type. constant evaluate(const expression& e, const query_options&); -constant evaluate(const bind_variable&, const query_options&); -constant evaluate(const tuple_constructor&, const query_options&); -constant evaluate(const collection_constructor&, const query_options&); -constant evaluate(const usertype_constructor&, const query_options&); -constant evaluate(const function_call&, const query_options&); utils::chunked_vector get_list_elements(const constant&); utils::chunked_vector get_set_elements(const constant&);