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:
parent
0e6a6ea0b1
commit
6a93a121f3
1 changed files with 11 additions and 8 deletions
19
ircd/json.cc
19
ircd/json.cc
|
@ -3983,16 +3983,19 @@ ircd::json::serialized(const value &v)
|
|||
if(!v.string)
|
||||
return size(empty_string);
|
||||
|
||||
thread_local char test_buffer[value::max_string_size];
|
||||
const string_view sv{v.string, v.len};
|
||||
mutable_buffer buf{test_buffer};
|
||||
const string_view sv
|
||||
{
|
||||
v.string, v.len
|
||||
};
|
||||
|
||||
if(v.serial)
|
||||
printer(buf, printer.string, json::string(sv));
|
||||
else
|
||||
printer(buf, printer.string, sv);
|
||||
const auto ret
|
||||
{
|
||||
v.serial?
|
||||
json::string::serialized(json::string(sv)):
|
||||
json::string::serialized(sv)
|
||||
};
|
||||
|
||||
return begin(buf) - test_buffer;
|
||||
return 1 + ret + 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue