Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: SSO – Small String Optimization (github.com/feelamee)
4 points by feelamee 3 days ago | hide | past | favorite | 2 comments
I wrote this just for fun when saw article about sso in Rust[1]. My string can store up to 23 (excluding null-terminator) 8-bit chars without calling allocator.

Here I can mistake, but.. Curious fact: both - libstdc++[2] and libc++[3] - do access to union member without any check that it is active now. AFAIK, this is UB in C++. But I assume that they just rely on theirs compiler features. I tried to avoid this using `std::byte[]`. But I'm still sure that there are several UB's in my code :)

[1] https://tunglevo.com/note/an-optimization-thats-impossible-i...

[2] https://github.com/gcc-mirror/gcc/blob/d09131eea083e80ccad60...

[3] https://github.com/llvm/llvm-project/blob/4468d58080d0502a05...






Interesting. The writing is a little unclear, but I enjoyed nonetheless!

Here's my user test:

https://news.pub/?try=https://www.youtube.com/embed/tQXoCbUh...


Sure, I need to add some descriptions for people who don't know what it is before seeing my implementation.

Thanks for the review!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: