1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

Optimize output vector adapter write (#3569)

* Add benchmark for cbor serialization and cbor binary data serialization

* Use std::vector::insert method instead of std::copy in output_vector_adapter::write_characters

This change increases a lot the performance when writing lots of binary data.
This commit is contained in:
Romain Reignier
2022-07-08 08:12:00 +02:00
committed by GitHub
parent 7d361ec8ef
commit d4daaa897f
3 changed files with 63 additions and 2 deletions

View File

@ -14250,7 +14250,7 @@ class output_vector_adapter : public output_adapter_protocol<CharType>
JSON_HEDLEY_NON_NULL(2)
void write_characters(const CharType* s, std::size_t length) override
{
std::copy(s, s + length, std::back_inserter(v));
v.insert(v.end(), s, s + length);
}
private: