mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-31 03:56:42 +00:00
types: Don't wrap tombstone in an std::optional
All the callers of do_serialize_mutation_form pass a valid tombstone that is converted into a non-empty optional. This happens even if the tombstone is empty (tombstone::timestamp == api::missing_timestamp). This patch fixes this by passing in a reference to the tombstone which is convertible to bool, based on whether it is empty or not. Signed-off-by: Duarte Nunes <duarte@scylladb.com> Message-Id: <1460620528-3628-1-git-send-email-duarte@scylladb.com>
This commit is contained in:
committed by
Tomasz Grabiec
parent
40c1b29701
commit
f8d8dbdeb7
8
types.cc
8
types.cc
@@ -1826,7 +1826,7 @@ bool collection_type_impl::is_any_live(collection_mutation_view cm, tombstone to
|
||||
template <typename Iterator>
|
||||
collection_mutation
|
||||
do_serialize_mutation_form(
|
||||
std::experimental::optional<tombstone> tomb,
|
||||
const tombstone& tomb,
|
||||
boost::iterator_range<Iterator> cells) {
|
||||
auto element_size = [] (size_t c, auto&& e) -> size_t {
|
||||
return c + 8 + e.first.size() + e.second.serialize().size();
|
||||
@@ -1834,14 +1834,14 @@ do_serialize_mutation_form(
|
||||
auto size = accumulate(cells, (size_t)4, element_size);
|
||||
size += 1;
|
||||
if (tomb) {
|
||||
size += sizeof(tomb->timestamp) + sizeof(tomb->deletion_time);
|
||||
size += sizeof(tomb.timestamp) + sizeof(tomb.deletion_time);
|
||||
}
|
||||
bytes ret(bytes::initialized_later(), size);
|
||||
bytes::iterator out = ret.begin();
|
||||
*out++ = bool(tomb);
|
||||
if (tomb) {
|
||||
write(out, tomb->timestamp);
|
||||
write(out, tomb->deletion_time.time_since_epoch().count());
|
||||
write(out, tomb.timestamp);
|
||||
write(out, tomb.deletion_time.time_since_epoch().count());
|
||||
}
|
||||
auto writeb = [&out] (bytes_view v) {
|
||||
serialize_int32(out, v.size());
|
||||
|
||||
Reference in New Issue
Block a user