Optimize getline(istream&, fbstring&) implementation
authorGiuseppe Ottaviano <ott@fb.com>
Fri, 29 Jan 2016 15:02:58 +0000 (07:02 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Fri, 29 Jan 2016 15:20:23 +0000 (07:20 -0800)
commit116f13d81d9816da852999f87f5fa7387d79f842
treead33d4cbd85660adde39ce9f4bf0571cc1fe4c5e
parent754568a3ca0583bc4aa9f64a5b09fa9c3743876f
Optimize getline(istream&, fbstring&) implementation

Summary:
Current `getline` implementation in `fbstring` always allocates, even if the passed string is already large enough. Furthermore, the growing strategy relies on outdated assumptions about the allocator.
This implementation reuses the existing allocation as much as possible, then uses exponential growth.

Reviewed By: luciang, philippv

Differential Revision: D2871976

fb-gh-sync-id: 8db9512030be3f4953efa8f008747827504c032c
folly/FBString.h
folly/test/FBStringBenchmark.cpp
folly/test/FBStringTest.cpp
folly/test/FBStringTestBenchmarks.cpp.h