Correct a warning from cppcheck:
binary_writer.hpp:869: (style) Consider using std::accumulate algorithm instead of a raw loop.
910a7d2b87/checks (step)
:5:107
Signed-off-by: Xav83 <x.jouvenot@gmail.com>
This commit is contained in:
parent
b9dfdbe6be
commit
13a7c60257
1 changed files with 3 additions and 4 deletions
|
@ -861,13 +861,12 @@ class binary_writer
|
|||
*/
|
||||
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value)
|
||||
{
|
||||
std::size_t embedded_document_size = 0ul;
|
||||
std::size_t array_index = 0ul;
|
||||
|
||||
for (const auto& el : value)
|
||||
const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), 0ul, [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
|
||||
{
|
||||
embedded_document_size += calc_bson_element_size(std::to_string(array_index++), el);
|
||||
}
|
||||
return result + calc_bson_element_size(std::to_string(array_index++), el);
|
||||
});
|
||||
|
||||
return sizeof(std::int32_t) + embedded_document_size + 1ul;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue