felixguendling / cista

Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.
https://cista.rocks
MIT License
1.8k stars 113 forks source link

String gives different size at "empty" input for short/non_short #190

Open ChemistAion opened 1 year ago

ChemistAion commented 1 year ago

Continuing from: https://github.com/felixguendling/cista/issues/189

Consider this:

constexpr auto limit = cista::generic_string<>::short_length_limit;
using string = cista::raw::string;

auto size_m3 = string("", limit - 3).size();
auto size_m1 = string("", limit - 1).size();
auto size_m0 = string("", limit - 0).size();
auto size_p0 = string("", limit + 0).size();
auto size_p1 = string("", limit + 1).size();
auto size_p3 = string("", limit + 3).size();

Everything above small-optimization limit gives "right size", i.e.: size_p1 is 16 and size_p3 is 18, whereas non-heaps gives 0. Would be nice to get consistent behavior here.

...be sparkled :partying_face: by an idea from: https://github.com/felixguendling/cista/issues/187#issuecomment-1603128882

ChemistAion commented 10 months ago

I will check the impact here of what @khng300 did in the: https://github.com/felixguendling/cista/issues/187

ChemistAion commented 4 months ago

...just for the note here: described behavior is still persisted as for now (27.05.2024, HEAD commit ce041ab).