mutation_reader: optimize make_reader_returning()

make_reader_returning() is used by the single-key query path, and is slowed
down by needlessly allocating a vector, which is initialized by copying
the mutation (as initializer_list<> can not be moved from).

Fix by giving it its own implementation instead of relying on
make_reader_returning_many().
This commit is contained in:
Avi Kivity
2015-08-27 10:26:33 +03:00
committed by Tomasz Grabiec
parent 5f62f7a288
commit 16d6daba64

View File

@@ -158,7 +158,14 @@ make_lazy_reader(std::function<mutation_reader ()> make_reader) {
}
mutation_reader make_reader_returning(mutation m) {
return make_reader_returning_many({std::move(m)});
return [m = std::move(m), done = false] () mutable {
if (done) {
return make_ready_future<mutation_opt>();
} else {
done = true;
return make_ready_future<mutation_opt>(std::move(m));
}
};
}
mutation_reader make_reader_returning_many(std::vector<mutation> mutations) {