Get the latest tech news

Jank's new persistent string is fast (2023)


jank has a new C++ string class which is smaller and faster than std::string and folly::fbstring in benchmarks. How does it work?

Be as fast, or faster, than std::string and folly::fbstring Support hashing, with cached value Be immutable (i.e. no copy on substrings, writes only done in constructors, no mutators) Not a goal: Complete standard compliance (which allows me to cheat) It shares data, reduces allocations for strings all the way up to 23 bytes (which fits most keywords, I'd bet), and supports fast, memoized hashing. I optimized aspects of data locality, write ordering, branch elimination, tricks to enable constexpr even for complex code (like reinterpret_cast), etc.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Jank

Jank