From e33794f7c6728fc0748d3241a27316e62c4c1e35 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 13 Sep 2016 11:24:35 -0700 Subject: [PATCH] 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 --- folly/json.cpp | 1 - 1 file changed, 1 deletion(-) 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()); -- 2.34.1