Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/include/denc.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,16 @@ namespace _denc {
static void bound_encode(const container& s, size_t& p, uint64_t f = 0) {
p += sizeof(uint32_t);
if constexpr (traits::bounded) {
const auto elem_num = s.size();
#if _GLIBCXX_USE_CXX11_ABI
// intensionally not calling container's empty() method to not prohibit
// compiler from optimizing the check if it and the ::size() operate on
// different memory (observed when std::list::empty() works on pointers,
// not the size field).
if (elem_num) {
if (const auto elem_num = s.size(); elem_num > 0) {
#else
if (!s.empty()) {
const auto elem_num = s.size();
#endif
// STL containers use weird element types like std::pair<const K, V>;
// cast to something we have denc_traits for.
size_t elem_size = 0;
Expand Down