ring_position_exponential_vector_sharder: Take ranges by rvalue

Avoids some copies.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
Message-Id: <20170814093310.29200-1-duarte@scylladb.com>
This commit is contained in:
Duarte Nunes
2017-08-14 11:33:10 +02:00
committed by Avi Kivity
parent cb2c5016ea
commit ec75eac37d
4 changed files with 8 additions and 7 deletions

View File

@@ -363,8 +363,8 @@ ring_position_exponential_sharder::next(const schema& s) {
}
ring_position_exponential_vector_sharder::ring_position_exponential_vector_sharder(const std::vector<nonwrapping_range<ring_position>>& ranges)
: _ranges(std::begin(ranges), std::end(ranges)) {
ring_position_exponential_vector_sharder::ring_position_exponential_vector_sharder(const std::vector<nonwrapping_range<ring_position>>&& ranges) {
std::move(ranges.begin(), ranges.end(), std::back_inserter(_ranges));
if (!_ranges.empty()) {
_current_sharder.emplace(_ranges.front());
_ranges.pop_front();

View File

@@ -641,7 +641,7 @@ class ring_position_exponential_vector_sharder {
stdx::optional<ring_position_exponential_sharder> _current_sharder;
unsigned _element = 0;
public:
explicit ring_position_exponential_vector_sharder(const std::vector<nonwrapping_range<ring_position>>& ranges);
explicit ring_position_exponential_vector_sharder(const std::vector<nonwrapping_range<ring_position>>&& ranges);
stdx::optional<ring_position_exponential_vector_sharder_result> next(const schema& s);
};

View File

@@ -4073,18 +4073,19 @@ struct partition_range_and_sort_key {
};
future<foreign_ptr<lw_shared_ptr<reconcilable_result>>, cache_temperature>
storage_proxy::query_nonsingular_mutations_locally(schema_ptr s, lw_shared_ptr<query::read_command> cmd, const dht::partition_range_vector& prs,
storage_proxy::query_nonsingular_mutations_locally(schema_ptr s, lw_shared_ptr<query::read_command> cmd, const dht::partition_range_vector&& prs,
tracing::trace_state_ptr trace_state, uint64_t max_size) {
// no one permitted us to modify *cmd, so make a copy
auto shard_cmd = make_lw_shared<query::read_command>(*cmd);
auto range_count = static_cast<unsigned>(prs.size());
return do_with(cmd,
shard_cmd,
0u,
false,
static_cast<unsigned>(prs.size()),
range_count,
std::unordered_map<element_and_shard, partition_range_and_sort_key>{},
mutation_result_merger{s, cmd},
dht::ring_position_exponential_vector_sharder{prs},
dht::ring_position_exponential_vector_sharder{std::move(prs)},
global_schema_ptr(s),
tracing::global_trace_state_ptr(std::move(trace_state)),
cache_temperature(0.0f),

View File

@@ -279,7 +279,7 @@ private:
template<typename Range>
future<> mutate_internal(Range mutations, db::consistency_level cl, bool counter_write, tracing::trace_state_ptr tr_state, stdx::optional<clock_type::time_point> timeout_opt = { });
future<foreign_ptr<lw_shared_ptr<reconcilable_result>>, cache_temperature> query_nonsingular_mutations_locally(
schema_ptr s, lw_shared_ptr<query::read_command> cmd, const dht::partition_range_vector& pr, tracing::trace_state_ptr trace_state, uint64_t max_size);
schema_ptr s, lw_shared_ptr<query::read_command> cmd, const dht::partition_range_vector&& pr, tracing::trace_state_ptr trace_state, uint64_t max_size);
struct frozen_mutation_and_schema {
frozen_mutation fm;