Make fbstring::assign() tight, and simplify operator=() and append()
authorGiuseppe Ottaviano <ott@fb.com>
Tue, 23 Aug 2016 20:00:48 +0000 (13:00 -0700)
committerFacebook Github Bot 1 <facebook-github-bot-1-bot@fb.com>
Tue, 23 Aug 2016 20:08:41 +0000 (13:08 -0700)
commitaeef60dd4a7057444a1a3857f51e7ab462d320a3
tree5003ca0eda5a58b981f8be1074cf26f2dbd17d8a
parent89166c82417a52f99dd373f510dd5119574dbf33
Make fbstring::assign() tight, and simplify operator=() and append()

Summary:
`fbstring::assign()` uses `append()`, which triggers exponential growth, but it's preferable that `assign()` behaves like the `fbstring(const char*, size_t)` constructor, which is tight.

Also rewrite `operator=()` in terms of `assign()`, to avoid duplicating the logic, and refactor the logic of `append()` for the aliasing case so that it uses the same expansion operation as the non-aliasing case.

Reviewed By: luciang

Differential Revision: D3754932

fbshipit-source-id: 5423f2a360b4268b6a05dd0ae9d2fe5bd1eb855d
folly/FBString.h