cql3: Pass sstrings as const& where applicable

This commit is contained in:
Tomasz Grabiec
2015-02-03 11:18:02 +01:00
parent 213d029a22
commit d243fb7a01
16 changed files with 29 additions and 29 deletions

View File

@@ -31,7 +31,7 @@
namespace cql3 {
::shared_ptr<term> abstract_marker::raw::prepare(sstring keyspace, ::shared_ptr<column_specification> receiver)
::shared_ptr<term> abstract_marker::raw::prepare(const sstring& keyspace, ::shared_ptr<column_specification> receiver)
{
auto receiver_type = ::dynamic_pointer_cast<db::marshal::collection_type>(receiver->type);
if (receiver_type != nullptr) {
@@ -45,7 +45,7 @@ namespace cql3 {
assert(0);
}
::shared_ptr<term> abstract_marker::in_raw::prepare(sstring keyspace, ::shared_ptr<column_specification> receiver) {
::shared_ptr<term> abstract_marker::in_raw::prepare(const sstring& keyspace, ::shared_ptr<column_specification> receiver) {
return ::make_shared<lists::marker>(_bind_index, make_in_receiver(receiver));
}

View File

@@ -68,9 +68,9 @@ public:
: _bind_index{bind_index}
{ }
virtual ::shared_ptr<term> prepare(sstring keyspace, ::shared_ptr<column_specification> receiver) override;
virtual ::shared_ptr<term> prepare(const sstring& keyspace, ::shared_ptr<column_specification> receiver) override;
virtual assignment_testable::test_result test_assignment(sstring keyspace, ::shared_ptr<column_specification> receiver) override {
virtual assignment_testable::test_result test_assignment(const sstring& keyspace, ::shared_ptr<column_specification> receiver) override {
return assignment_testable::test_result::WEAKLY_ASSIGNABLE;
}
@@ -97,7 +97,7 @@ public:
return ::make_shared<column_specification>(receiver->ks_name, receiver->cf_name, in_name, db::marshal::list_type::get_instance(receiver->type, false));
}
virtual ::shared_ptr<term> prepare(sstring keyspace, ::shared_ptr<column_specification> receiver) override;
virtual ::shared_ptr<term> prepare(const sstring& keyspace, ::shared_ptr<column_specification> receiver) override;
};
};

View File

@@ -49,7 +49,7 @@ public:
// Test all elements of toTest for assignment. If all are exact match, return exact match. If any is not assignable,
// return not assignable. Otherwise, return weakly assignable.
static test_result test_all(sstring keyspace, ::shared_ptr<column_specification> receiver, const std::vector<::shared_ptr<assignment_testable>>& to_test) {
static test_result test_all(const sstring& keyspace, ::shared_ptr<column_specification> receiver, const std::vector<::shared_ptr<assignment_testable>>& to_test) {
test_result res = test_result::EXACT_MATCH;
for (auto&& rt : to_test) {
if (rt == nullptr) {
@@ -77,7 +77,7 @@ public:
* Most caller should just call the isAssignable() method on the result, though functions have a use for
* testing "strong" equality to decide the most precise overload to pick when multiple could match.
*/
virtual test_result test_assignment(sstring keyspace, ::shared_ptr<column_specification> receiver) = 0;
virtual test_result test_assignment(const sstring& keyspace, ::shared_ptr<column_specification> receiver) = 0;
};
}

View File

@@ -53,7 +53,7 @@ private:
{ }
public:
bool uses_function(sstring ks_name, sstring function_name) const {
bool uses_function(const sstring& ks_name, const sstring& function_name) const {
return (_timestamp && _timestamp.value()->uses_function(ks_name, function_name))
|| (_time_to_live && _time_to_live.value()->uses_function(ks_name, function_name));
}
@@ -126,18 +126,18 @@ public:
::shared_ptr<term::raw> timestamp;
::shared_ptr<term::raw> time_to_live;
std::unique_ptr<attributes> prepare(sstring ks_name, sstring cf_name) {
std::unique_ptr<attributes> prepare(const sstring& ks_name, const sstring& cf_name) {
auto ts = !timestamp ? ::shared_ptr<term>{} : timestamp->prepare(ks_name, timestamp_receiver(ks_name, cf_name));
auto ttl = !time_to_live ? ::shared_ptr<term>{} : time_to_live->prepare(ks_name, time_to_live_receiver(ks_name, cf_name));
return std::unique_ptr<attributes>{new attributes{std::move(ts), std::move(ttl)}};
}
private:
::shared_ptr<column_specification> timestamp_receiver(const sstring ks_name, sstring cf_name) {
::shared_ptr<column_specification> timestamp_receiver(const sstring& ks_name, const sstring& cf_name) {
return ::make_shared<column_specification>(ks_name, cf_name, ::make_shared<column_identifier>("[timestamp]", true), data_type_for<int64_t>());
}
::shared_ptr<column_specification> time_to_live_receiver(sstring ks_name, sstring cf_name) {
::shared_ptr<column_specification> time_to_live_receiver(const sstring& ks_name, const sstring& cf_name) {
return ::make_shared<column_specification>(ks_name, cf_name, ::make_shared<column_identifier>("[ttl]", true), data_type_for<int32_t>());
}
};

View File

@@ -106,7 +106,7 @@ public:
}
#endif
bool uses_function(sstring ks_name, sstring function_name) const {
bool uses_function(const sstring& ks_name, const sstring& function_name) const {
throw std::runtime_error("not implemented");
#if 0
if (collectionElement != null && collectionElement.usesFunction(ksName, functionName))

View File

@@ -142,7 +142,7 @@ public:
return ::make_shared<literal>(type::HEX, text);
}
virtual ::shared_ptr<term> prepare(sstring keyspace, ::shared_ptr<column_specification> receiver) override {
virtual ::shared_ptr<term> prepare(const sstring& keyspace, ::shared_ptr<column_specification> receiver) override {
throw std::runtime_error("not implemented");
#if 0
if (!testAssignment(keyspace, receiver).isAssignable())
@@ -177,7 +177,7 @@ public:
}
#endif
virtual assignment_testable::test_result test_assignment(sstring keyspace, ::shared_ptr<column_specification> receiver) override {
virtual assignment_testable::test_result test_assignment(const sstring& keyspace, ::shared_ptr<column_specification> receiver) override {
throw new std::runtime_error("not implemented");
#if 0
CQL3Type receiverType = receiver.type.asCQL3Type();

View File

@@ -72,7 +72,7 @@ public:
virtual future<std::experimental::optional<transport::messages::result_message>>
execute_internal(service::query_state& state, const query_options& options) = 0;
virtual bool uses_function(sstring ks_name, sstring function_name) const = 0;
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const = 0;
};
}

View File

@@ -66,7 +66,7 @@ public:
&& _return_type == x._return_type;
}
virtual bool uses_function(sstring ks_name, sstring function_name) override {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) override {
return _name.keyspace == ks_name && _name.name == function_name;
}

View File

@@ -64,7 +64,7 @@ public:
virtual void print(std::ostream& os) const = 0;
protected:
virtual bool uses_function(sstring ks_name, sstring function_name) = 0;
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) = 0;
virtual bool has_reference_to(function& f) = 0;
friend class function_call;
friend std::ostream& operator<<(std::ostream& os, const function& f);

View File

@@ -41,8 +41,8 @@ public:
: _fun(std::move(fun)), _terms(std::move(terms)) {
}
virtual bool uses_function(sstring ks_name, sstring function_name) const override {
return _fun->uses_function(std::move(ks_name), std::move(function_name));
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const override {
return _fun->uses_function(ks_name, function_name);
}
virtual void collect_marker_specification(shared_ptr<variable_specifications> bound_names) override {

View File

@@ -77,7 +77,7 @@ protected:
{ }
public:
virtual bool uses_function(sstring ks_name, sstring function_name) const {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const {
return _t && _t->uses_function(ks_name, function_name);
}

View File

@@ -56,7 +56,7 @@ public:
* @param functionName the function name
* @return <code>true</code> if one of the restrictions use the specified function, <code>false</code> otherwise.
*/
virtual bool uses_function(sstring ksName, sstring functionName) = 0;
virtual bool uses_function(const sstring& ksName, const sstring& functionName) = 0;
/**
* Checks if the specified bound is set or not.

View File

@@ -128,7 +128,7 @@ public:
, _column_operations{}
{ }
virtual bool uses_function(sstring ks_name, sstring function_name) const override {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const override {
if (attrs->uses_function(ks_name, function_name)) {
return true;
}

View File

@@ -78,7 +78,7 @@ public:
virtual std::unique_ptr<prepared> prepare(database& db) = 0;
virtual bool uses_function(sstring ks_name, sstring function_name) const {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const {
return false;
}
};

View File

@@ -49,7 +49,7 @@ public:
return std::make_unique<parsed_statement::prepared>(this->shared_from_this());
}
virtual bool uses_function(sstring ks_name, sstring function_name) const override {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const override {
return parsed_statement::uses_function(ks_name, function_name);
}

View File

@@ -83,7 +83,7 @@ public:
*/
virtual bool contains_bind_marker() const = 0;
virtual bool uses_function(sstring ks_name, sstring function_name) const = 0;
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const = 0;
/**
* A parsed, non prepared (thus untyped) term.
@@ -106,14 +106,14 @@ public:
* case this RawTerm describe a list index or a map key, etc...
* @return the prepared term.
*/
virtual ::shared_ptr<term> prepare(sstring keyspace, ::shared_ptr<column_specification> receiver) = 0;
virtual ::shared_ptr<term> prepare(const sstring& keyspace, ::shared_ptr<column_specification> receiver) = 0;
virtual sstring to_string() = 0;
};
class multi_column_raw : public virtual raw {
public:
virtual ::shared_ptr<term> prepare(sstring keyspace, const std::vector<column_specification>& receiver) = 0;
virtual ::shared_ptr<term> prepare(const sstring& keyspace, const std::vector<column_specification>& receiver) = 0;
};
};
@@ -140,7 +140,7 @@ public:
return this->shared_from_this();
}
virtual bool uses_function(sstring ks_name, sstring function_name) const override {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const override {
return false;
}
@@ -183,7 +183,7 @@ public:
*/
class non_terminal : public term {
public:
virtual bool uses_function(sstring ks_name, sstring function_name) const override {
virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const override {
return false;
}