From 7931ecb1318d7133f035dc76868b588403230944 Mon Sep 17 00:00:00 2001 From: Giuseppe Ottaviano Date: Fri, 27 May 2016 09:49:40 -0700 Subject: [PATCH] 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 --- folly/FBString.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; } -- 2.34.1