JSON: Added std::string::reserve to compensate for growth

This commit is contained in:
Paul Beckingham 2015-10-30 12:37:50 -04:00
parent 6ce3285c77
commit b4fc2b5583

View file

@ -377,6 +377,7 @@ json::value* json::parse (const std::string& input)
std::string json::encode (const std::string& input)
{
std::string output;
output.reserve ((input.size () * 6) / 5); // 20% increase.
for (auto& i : input)
{
@ -405,6 +406,8 @@ std::string json::encode (const std::string& input)
std::string json::decode (const std::string& input)
{
std::string output;
output.reserve (input.size ()); // Same size.
size_t pos = 0;
while (pos < input.length ())