From: Milo Yip Date: Tue, 13 Sep 2016 18:24:35 +0000 (-0700) Subject: Optimize toJson() Performance X-Git-Tag: v2016.09.19.00~17 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e33794f7c6728fc0748d3241a27316e62c4c1e35;p=folly.git 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 --- diff --git a/folly/json.cpp b/folly/json.cpp index f4607efd..105b1ca7 100644 --- a/folly/json.cpp +++ b/folly/json.cpp @@ -693,7 +693,6 @@ void escapeString( return c < 10 ? c + '0' : c - 10 + 'a'; }; - out.reserve(out.size() + input.size() + 2); out.push_back('\"'); auto* p = reinterpret_cast(input.begin());