From f8d8dbdeb7918ef9f2743b014ea6d7bade16f3fd Mon Sep 17 00:00:00 2001 From: Duarte Nunes Date: Thu, 14 Apr 2016 09:55:28 +0200 Subject: [PATCH] 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 Message-Id: <1460620528-3628-1-git-send-email-duarte@scylladb.com> --- types.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types.cc b/types.cc index b9d80f2a14..bfad7b035b 100644 --- a/types.cc +++ b/types.cc @@ -1826,7 +1826,7 @@ bool collection_type_impl::is_any_live(collection_mutation_view cm, tombstone to template collection_mutation do_serialize_mutation_form( - std::experimental::optional tomb, + const tombstone& tomb, boost::iterator_range 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());