-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge bitvec.rs
and indexed_set.rs
#54286
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
See #52028 (comment) for some measurements. |
@bors try |
Merge `bitvec.rs` and `indexed_set.rs` Because it's not good to have two separate implementations. Also, I will combine the best parts of each to improve NLL memory usage on some benchmarks significantly.
@@ -160,7 +160,7 @@ impl<T: Idx> BitSet<T> { | |||
/// Set `self = self & other` and return true if `self` changed. | |||
/// (i.e., if any bits were removed). | |||
pub fn intersect(&mut self, other: &BitSet<T>) -> bool { | |||
bitwise(self.words_mut(), other.words(), &Intersect) | |||
bitwise(self.words_mut(), other.words(), |a, b| { a & b }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I guess I can hope this always gets inlined even on debug builds (which I believe was a property of the former architecture here...)
r=me; I'd like some of the deleted documentation to be preserved, but I'm not going to block landing the PR on completion of that task. I'll let @nnethercote decide whether to port over the docs or not as I asked in a comment in my review. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r- CI failed. |
💥 Test timed out |
Currently we have two files implementing bitsets (and 2D bit matrices). This commit combines them into one, taking the best features from each. This involves renaming a lot of things. The high level changes are as follows. - bitvec.rs --> bit_set.rs - indexed_set.rs --> (removed) - BitArray + IdxSet --> BitSet (merged, see below) - BitVector --> GrowableBitSet - {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet - BitMatrix --> BitMatrix - SparseBitMatrix --> SparseBitMatrix The changes within the bitset types themselves are as follows. ``` OLD OLD NEW BitArray<C> IdxSet<T> BitSet<T> -------- ------ ------ grow - grow new - (remove) new_empty new_empty new_empty new_filled new_filled new_filled - to_hybrid to_hybrid clear clear clear set_up_to set_up_to set_up_to clear_above - clear_above count - count contains(T) contains(&T) contains(T) contains_all - superset is_empty - is_empty insert(T) add(&T) insert(T) insert_all - insert_all() remove(T) remove(&T) remove(T) words words words words_mut words_mut words_mut - overwrite overwrite merge union union - subtract subtract - intersect intersect iter iter iter ``` In general, when choosing names I went with: - names that are more obvious (e.g. `BitSet` over `IdxSet`). - names that are more like the Rust libraries (e.g. `T` over `C`, `insert` over `add`); - names that are more set-like (e.g. `union` over `merge`, `superset` over `contains_all`, `domain_size` over `num_bits`). Also, using `T` for index arguments seems more sensible than `&T` -- even though the latter is standard in Rust collection types -- because indices are always copyable. It also results in fewer `&` and `*` sigils in practice.
`BitwiseOperator` is an unnecessarily low-level thing. This commit replaces it with `BitSetOperator`, which works on `BitSet`s instead of words. Within `bit_set.rs`, the commit eliminates `Intersect`, `Union`, and `Subtract` by instead passing a function to `bitwise()`.
- Rename `BitSet::data` and `BitMatrix::vector` as `words`, because that's what they are. - Remove `BitSet::words_mut()`, which is no longer necessary. - Better distinguish multiple meanins of "word", i.e. "word index" vs "word ref" vs "word" (i.e. the value itself).
I have added comments about the index types, and fixed the problems with the tests. r=pnkfelix |
@bors r=pnkfelix |
📌 Commit 53589b7 has been approved by |
@bors p=3 (blocks some NLL memory usage work, according to IRC) |
Merge `bitvec.rs` and `indexed_set.rs` Because it's not good to have two separate implementations. Also, I will combine the best parts of each to improve NLL memory usage on some benchmarks significantly.
☀️ Test successful - status-appveyor, status-travis |
…x, r=pnkfelix Use `HybridBitSet` in `SparseBitMatrix`. This fixes most of the remaining NLL memory regression. r? @pnkfelix, because you reviewed #54286. cc @nikomatsakis, because NLL cc @Mark-Simulacrum, because this removes `array_vec.rs` cc @lqd, because this massively improves `unic-ucd-name`, and probably other public crates
…x, r=pnkfelix Use `HybridBitSet` in `SparseBitMatrix`. This fixes most of the remaining NLL memory regression. r? @pnkfelix, because you reviewed #54286. cc @nikomatsakis, because NLL cc @Mark-Simulacrum, because this removes `array_vec.rs` cc @lqd, because this massively improves `unic-ucd-name`, and probably other public crates
Because it's not good to have two separate implementations. Also, I will combine the best parts of each to improve NLL memory usage on some benchmarks significantly.