From 0edf975bf71b751af8a3b9f8f7589fa20030fcf0 Mon Sep 17 00:00:00 2001 From: Pavel Solodovnikov Date: Wed, 28 Jul 2021 23:31:32 +0300 Subject: [PATCH] cql3: make `prepare_context::get_variable_specifications()` return const-ref for lvalue overload There's no point in copying the `_specs` vector by value in such case, just return a const reference. All existing uses create a copy either way. Tests: unit(dev) Signed-off-by: Pavel Solodovnikov --- cql3/prepare_context.cc | 4 ++-- cql3/prepare_context.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cql3/prepare_context.cc b/cql3/prepare_context.cc index 10366ec788..4990aa8b7b 100644 --- a/cql3/prepare_context.cc +++ b/cql3/prepare_context.cc @@ -58,8 +58,8 @@ size_t prepare_context::bound_variables_size() const { return _variable_names.size(); } -std::vector> prepare_context::get_variable_specifications() const & { - return std::vector>(_specs.begin(), _specs.end()); +const std::vector>& prepare_context::get_variable_specifications() const & { + return _specs; } std::vector> prepare_context::get_variable_specifications() && { diff --git a/cql3/prepare_context.hh b/cql3/prepare_context.hh index bb8cccfc94..d01049143d 100644 --- a/cql3/prepare_context.hh +++ b/cql3/prepare_context.hh @@ -86,7 +86,7 @@ public: size_t bound_variables_size() const; - std::vector> get_variable_specifications() const &; + const std::vector>& get_variable_specifications() const &; std::vector> get_variable_specifications() &&;