|
|
|
|
|
by OskarS
2328 days ago
|
|
Yeah, exactly :) when in SSO mode, it stores the size as a delta occupying a single byte, but when in heap-allocated mode, it stores the size as a an 8-byte size_t, and you require a branch to check which case is the right one. You can see the branch here in the source [0], and godbolt confirms that for std::string it's just a memory load [1]. A shame Folly isn't available on Compiler Explorer, would be interesting to compare. [0]: https://github.com/facebook/folly/blob/master/folly/FBString... [1]: https://godbolt.org/z/U-LvGm |
|