danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
697 stars 160 forks source link

Centos7 build fix #519

Closed neandreithal closed 2 months ago

neandreithal commented 2 months ago

I've managed to get #507 working with llvm-toolset-7 on CentOS 7. Unfortunately, I can't move to devtoolset-9 as it was done in the original issue.

danielaparker commented 2 months ago

I appreciate the effort!

I'd like to avoid constructing strings with s.cstr(), as that would result in a large number of length recalculations, when we already know the length.

For key_type, you should replace

key_type(s->first.c_str(), get_allocator())

with

key_type(s->first.data(), s->first.size(), get_allocator())

Similarly, you should replace

 keys.emplace(key.c_str(), get_allocator());

with

 keys.emplace(key.data(), key.size(), get_allocator());
neandreithal commented 2 months ago

Done, thanks for the feedback!