Commit e33794f7 authored by Milo Yip's avatar Milo Yip Committed by Facebook Github Bot

Optimize toJson() Performance

Summary:
Removing string::reserve() which causes O(n^2) penalty.

Fixes #477
Closes https://github.com/facebook/folly/pull/478

Reviewed By: yfeldblum

Differential Revision: D3850509

Pulled By: Orvid

fbshipit-source-id: ecf44c35b2aedadc5385d23c325cacab1abfd02d
parent fe583120
...@@ -693,7 +693,6 @@ void escapeString( ...@@ -693,7 +693,6 @@ void escapeString(
return c < 10 ? c + '0' : c - 10 + 'a'; return c < 10 ? c + '0' : c - 10 + 'a';
}; };
out.reserve(out.size() + input.size() + 2);
out.push_back('\"'); out.push_back('\"');
auto* p = reinterpret_cast<const unsigned char*>(input.begin()); auto* p = reinterpret_cast<const unsigned char*>(input.begin());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment