From c7a59ab7ffca0d235437162bd87bbde91e01ca35 Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Wed, 14 Jun 2017 14:46:07 +0300 Subject: [PATCH] do not calculate serialized size of commitlog_entry_writer before final format is knows Currently commitlog_entry_writer constructor calculates serialized size before it is knows if a schema should be included into the entry. The result is never used since it is recalculated when schema information is supplied. The patch removes needless calculation. Message-Id: <20170614114607.GA21915@scylladb.com> --- db/commitlog/commitlog_entry.hh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/commitlog/commitlog_entry.hh b/db/commitlog/commitlog_entry.hh index 358e48624d..fc23f25805 100644 --- a/db/commitlog/commitlog_entry.hh +++ b/db/commitlog/commitlog_entry.hh @@ -42,7 +42,7 @@ class commitlog_entry_writer { schema_ptr _schema; const frozen_mutation& _mutation; bool _with_schema = true; - size_t _size; + size_t _size = std::numeric_limits::max(); private: template void serialize(Output&) const; @@ -50,9 +50,7 @@ private: public: commitlog_entry_writer(schema_ptr s, const frozen_mutation& fm) : _schema(std::move(s)), _mutation(fm) - { - compute_size(); - } + {} void set_with_schema(bool value) { _with_schema = value; @@ -66,6 +64,7 @@ public: } size_t size() const { + assert(_size != std::numeric_limits::max()); return _size; }