#reference-counting #string #sso #thin #atomically #pointers #big

arcstring

Atomically reference-counted thin string type with SSO

4 releases

0.1.3 Aug 25, 2024
0.1.2 Aug 24, 2024
0.1.1 Aug 24, 2024
0.1.0 Aug 24, 2024

#522 in Memory management

WTFPL license

17KB
431 lines

ArcString

This is a simple library that contains an atomically reference-counted string type that is only as big as one pointer, but is capable of SSO up to its size. So, when pointers are 64-bit, ArcString is 8 bytes large, and can store strings up to 8 bytes without a heap allocation, and when pointers are 32-bit, that is 4 bytes. It uses NonZeroUsize internally, meaning Option is also only as big as one pointer.

Dependencies

~42KB