rust-lang / hashbrown

Rust port of Google's SwissTable hash map
https://rust-lang.github.io/hashbrown
Apache License 2.0
2.46k stars 288 forks source link

Add Tag(u8) newtype in an attempt to stop using byte-pointers for everything #565

Closed clarfonthey closed 1 month ago

clarfonthey commented 1 month ago

The longer-term goal is to make it so that all the pointers passed around inside the are either Tag pointers or T pointers, so that we know whether we're using them for indexing into the control or the buckets. Then, u8 pointers mean that we're referring to a raw allocation, rather than the control bytes.

However, the current code isn't really built for this, and the result is a lot of pointer casts everywhere. I didn't want to just replace u8 with Tag everywhere, since there are some cases where we use u8 to really mean bytes, and that would be counter to the original purpose.

One short-term gain, however, is that the constant tags and the various methods on them can now be real associated constants and methods, instead of just standalone functions and constants that have to be imported separately.


This change also bumps MSRV to 1.65.0. I could bump it higher, but only 1.65 was needed, so, I decided to go with the smallest amount.

Amanieu commented 1 month ago

@bors r+

bors commented 1 month ago

:pushpin: Commit 4de01fe893d21a8c148b7aea69393585f2a909c3 has been approved by Amanieu

It is now in the queue for this repository.

bors commented 1 month ago

:hourglass: Testing commit 4de01fe893d21a8c148b7aea69393585f2a909c3 with merge ee00971aa7561b4dcec2b4c0167785d6cbdf1209...

bors commented 1 month ago

:sunny: Test successful - checks-actions Approved by: Amanieu Pushing ee00971aa7561b4dcec2b4c0167785d6cbdf1209 to master...