Disallow COW in FBString
[folly.git] / folly / docs / FBString.md
1 `folly/FBString.h`
2 ------------------
3
4 `fbstring` is a drop-in replacement for `std::string`. The main
5 benefit of `fbstring` is significantly increased performance on
6 virtually all important primitives. This is achieved by using a
7 two-tiered storage strategy and by cooperating with the memory
8 allocator. In particular, `fbstring` is designed to detect use of
9 jemalloc and cooperate with it to achieve significant improvements in
10 speed and memory usage.
11
12 `fbstring` supports 32- and 64-bit and little- and big-endian
13 architectures.
14
15 ### Storage strategies
16 ***
17
18 * Small strings (<= 23 chars) are stored in-situ without memory
19   allocation.
20
21 * Other strings (> 23 chars) are stored in malloc-allocated
22   memory and copied eagerly.
23
24 ### Implementation highlights
25 ***
26
27 * 100% compatible with `std::string`.
28
29 * Uses `malloc` instead of allocators.
30
31 * Jemalloc-friendly. `fbstring` automatically detects if application
32   uses jemalloc and if so, significantly improves allocation
33   strategy by using non-standard jemalloc extensions.
34
35 * `find()` is implemented using simplified Boyer-Moore
36   algorithm. Casual tests indicate a 30x speed improvement over
37   `string::find()` for successful searches and a 1.5x speed
38   improvement for failed searches.
39
40 * Offers conversions to and from `std::string`.