0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 23:40:57 +01:00

ircd::json: Optimize serialized(value) string case.

This commit is contained in:
Jason Volk 2020-07-03 18:03:54 -07:00
parent 0e6a6ea0b1
commit 6a93a121f3

View file

@ -3983,16 +3983,19 @@ ircd::json::serialized(const value &v)
if(!v.string) if(!v.string)
return size(empty_string); return size(empty_string);
thread_local char test_buffer[value::max_string_size]; const string_view sv
const string_view sv{v.string, v.len}; {
mutable_buffer buf{test_buffer}; v.string, v.len
};
if(v.serial) const auto ret
printer(buf, printer.string, json::string(sv)); {
else v.serial?
printer(buf, printer.string, sv); json::string::serialized(json::string(sv)):
json::string::serialized(sv)
};
return begin(buf) - test_buffer; return 1 + ret + 1;
} }
}; };