Skip to content

Commit 7e99e73

Browse files
committed
Add themplate Id to the pmap size calculation
1 parent a74af23 commit 7e99e73

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/mfast/coder/encoder/fast_encoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ void fast_encoder_impl::visit(message_cref cref, bool force_reset) {
174174
template_instruction *instruction = *this->find(template_id);
175175

176176
if (instruction != nullptr) {
177-
current_pmap().init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size(), 1));
177+
constexpr std::size_t template_id_bit = 1;
178+
current_pmap().init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size() + template_id_bit, 1));
178179
} else {
179180
using namespace coder;
180181
BOOST_THROW_EXCEPTION(fast_dynamic_error("D9")

src/mfast/coder/encoder_v2/fast_encoder_core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void fast_encoder_core::encode_segment(const message_cref cref,
2323

2424
encoder_presence_map pmap;
2525
this->current_ = &pmap;
26-
pmap.init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size(), 1));
26+
constexpr std::size_t template_id_bit = 1;
27+
pmap.init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size() + template_id_bit, 1));
2728
pmap.set_next_bit(need_encode_template_id);
2829

2930
if (need_encode_template_id) {

0 commit comments

Comments
 (0)