logoalt Hacker News

nextaccounticyesterday at 7:07 PM1 replyview on HN

UTF-8 also enables this mindblowing design for small string optimization - if the string has 24 bytes or less it is stored inline, otherwise it is stored on the heap (with a pointer, a length, and a capacity - also 24 bytes)

https://github.com/ParkMyCar/compact_str

How cool is that

(Discussed here https://news.ycombinator.com/item?id=41339224)


Replies

adgjlsfhk1yesterday at 8:32 PM

How is that UTF8 specific?

show 2 replies