Simplify fbstring::insertImpl
authorGiuseppe Ottaviano <ott@fb.com>
Thu, 31 Mar 2016 20:39:21 +0000 (13:39 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Thu, 31 Mar 2016 20:50:29 +0000 (13:50 -0700)
commit8ddc5992d18f45c3608fb9d6d3c1e4dfa106831a
tree9ce8153143ea8a2a18cc279cdb6d29b6bbf2bddc
parent2cf0e317216da1a49539cd011055af9a2ae121a9
Simplify fbstring::insertImpl

Summary:The current implementation of `insertImpl` assumes that
`expand_noinit` does not reallocate if the `size() + delta <=
capacity()`, but D3114022 makes this assumption invalid when compiling
with ASan. It also doesn't guarantee exponential growth, so repeated
inserting at the end could trigger quadratic behavior.

The new implementation fixes the problems above, and it's much
simpler.

Reviewed By: yfeldblum, Orvid

Differential Revision: D3119813

fb-gh-sync-id: 946ebeeaf924a531f7f03fb7e79c75e352a50c58
fbshipit-source-id: 946ebeeaf924a531f7f03fb7e79c75e352a50c58
folly/FBString.h