anderslanglands / ustr

Fast, FFI-friendly string interning for Rust
Other
151 stars 26 forks source link

Added space optimization to Ustr #14

Closed TrolledWoods closed 4 years ago

TrolledWoods commented 4 years ago

Since the pointer inside Ustr is never supposed to be null anyway it felt like a waste to not space optimize it.

anderslanglands commented 4 years ago

Thanks, this is a great idea. Just so I understand correctly , this doesn’t really change anything in Ustr itself but allows space optimisations where a Ustr is stored in e.g. an Option?

TrolledWoods commented 4 years ago

Yes, NonNull is just a pointer under the hood like *const T is but it has an invariant that it's not null that the compiler knows about.