The power-law distribution of string sizes means that you get a surprising amount of benefit from optimizing the case of zero-length strings and nothing else (which is what Rust does). Happily, zero-length string/vector optimization is basically free.
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
yeah, just from looking at what the generated code does when reversing C++, it feels pretty sketchy- "get pointer to string contents" is now a branch, and one that can be unpredictable anytime you have varying string lengths (not uncommon, I suspect!)
-
I wouldn't be surprised if the benchmarks to justify the optimization were done long ago on slow mallocs like that of msvcrt, and nobody bothered to test again now that we have fast mallocs like jemalloc.
- 2 more replies
New conversation -
-
-
Code bloat because all the if-small-else-big logic get inlined all over the place?
- 3 more replies
New conversation -
-
-
It's a bit of a questionable thing in general because a code-base in general should not really be having those kinds of problems. So I think the opt-in stack allocated array type is the way to go. Can be used where it's really useful, and ignored otherwise.
-
This might also be a bit of a rust thing also, where move semantics stop a lot of the accidental copying that can end up pervading C++.
- 1 more reply
New conversation -
-
-
Just improving our SSO from libstdc++ std::string to fbstring for path components was a tens of megabytes RSS improvement in EdenFS.
-
Weird flex::string
End of conversation
New conversation -
-
-
The small string optimization can have a tricky side effect: It creates pointers *inside* of the string object. If you use a faster/simpler std::vector replacement that assumes it can freely memcpy() around its contents, this won't work. Once the object moves the pointers break.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.