From: Giuseppe Ottaviano Date: Fri, 27 May 2016 16:49:40 +0000 (-0700) Subject: Use exponential growth in fbstring::append(size_type n, value_type c) X-Git-Tag: 2016.07.26~196 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7931ecb1318d7133f035dc76868b588403230944;p=folly.git Use exponential growth in fbstring::append(size_type n, value_type c) Summary: Contrary to the other `append` flavors, `fbstring::append(size_type n, value_type c)` does not use exponential growth, which can trigger quadratic behavior. Reviewed By: philippv Differential Revision: D3357315 fbshipit-source-id: 2301ed1a9953544368663107113890a25c6621ae --- diff --git a/folly/FBString.h b/folly/FBString.h index 346d23c4..0c8273e5 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -1338,7 +1338,9 @@ public: } basic_fbstring& append(size_type n, value_type c) { - resize(size() + n, c); + Invariant checker(*this); + auto pData = store_.expand_noinit(n, /* expGrowth = */ true); + fbstring_detail::pod_fill(pData, pData + n, c); return *this; }