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)
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue