mirror of
https://github.com/monero-project/monero.git
synced 2026-01-16 06:42:52 -08:00
Switch to insitu parsing for ZMQ-JSON; GetBlocksFast reads 13%+ faster
This commit is contained in:
@@ -79,9 +79,12 @@ void Message::fromJson(const rapidjson::Value& val)
|
||||
GET_FROM_JSON_OBJECT(val, rpc_version, rpc_version);
|
||||
}
|
||||
|
||||
FullMessage::FullMessage(const std::string& json_string, bool request)
|
||||
FullMessage::FullMessage(std::string&& json_string, bool request)
|
||||
: contents(std::move(json_string)), doc()
|
||||
{
|
||||
doc.Parse(json_string.c_str());
|
||||
/* Insitu parsing does not copy data from `contents` to DOM,
|
||||
accelerating string heavy content. */
|
||||
doc.ParseInsitu(std::addressof(contents[0]));
|
||||
if (doc.HasParseError() || !doc.IsObject())
|
||||
{
|
||||
throw cryptonote::json::PARSE_FAIL();
|
||||
|
||||
Reference in New Issue
Block a user