about summary refs log tree commit diff
path: root/src/librustc_data_structures/bitvec.rs
AgeCommit message (Collapse)AuthorLines
2018-09-18Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs.Nicholas Nethercote-781/+0
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.
2018-09-13Remove bitslice.rs.Nicholas Nethercote-37/+200
This requires the following changes. - It moves parts of bitslice.rs into bitvec.rs: `bitwise()`, `BitwiseOperator`, `bits_to_string()`. - It changes `IdxSet` to just be a wrapper around `BitArray`. - It changes `BitArray` and `BitVec` to use `usize` words instead of `u128` words. (`BitSlice` and `IdxSet` already use `usize`.) Local profiling showed `usize` was better. - It moves some operations from `IdxSet` into `BitArray`: `new_filled()`, `clear()`, `set_up_to()`, `trim_to()` (renamed `clear_above()`), `words()` and `words_mut()`, `encode()` and `decode(). The `IdxSet` operations now just call the `BitArray` operations. - It replaces `BitArray`'s iterator implementation with `IdxSet`'s, because the latter is more concise. It also removes the buggy `size_hint` function from `BitArray`'s iterator, which counted the number of *words* rather than the number of *bits*. `IdxSet`'s iterator is now just a thin wrapper around `BitArray`'s iterator. - It moves some unit tests from `indexed_set.rs` to `bitvec.rs`.
2018-09-13Reorder bitvec.rs.Nicholas Nethercote-40/+37
So that the `BitArray` code is all together and before the `BitVector` code, instead of being awkwardly interleaved.
2018-08-23Make SparseBitMatrix a bit lazier.Nicholas Nethercote-28/+32
Currently when a row is instantiated in SparseBitMatrix, any missing rows prior to it are also fully instantiated. This patch changes things so that those prior rows are minimally instantiated (with a `None`). This avoids a decent number of allocations in NLL, speeding up several benchmarks by up to 0.5%. The patch also removes two unused methods, `len()` and `iter_enumerated()`.
2018-08-23Rename the fields in `SparseBitMatrix`.Nicholas Nethercote-19/+19
The new names are clearer.
2018-08-09A few cleanups for rustc_data_structuresljedrz-2/+3
2018-08-01Split out growth functionality into BitVector typeMark Rousskov-55/+73
2018-07-26fix `sparse_matrix_iter` unit testNiko Matsakis-1/+1
2018-07-26add type parameters to `BitMatrix` and `SparseBitMatrix` unit testsNiko Matsakis-3/+3
2018-07-26convert tests of `BitVector` to use `BitVector<usize>`Niko Matsakis-5/+5
2018-07-25SparseBitMatrix: add `insert_all` and `add_all` methodsNiko Matsakis-0/+13
2018-07-25SparseBitMatrix: add `ensure_row` helper fnNiko Matsakis-9/+9
2018-07-25split into two matricesNiko Matsakis-0/+61
2018-07-25parameterize `BitVector` and `BitMatrix` by their index typesNiko Matsakis-39/+50
2018-07-20Speed up `SparseBitMatrix`.Nicholas Nethercote-208/+28
Using a `BTreeMap` to represent rows in the bit matrix is really slow. This patch changes things so that each row is represented by a `BitVector`. This is a less sparse representation, but a much faster one. As a result, `SparseBitSet` and `SparseChunk` can be removed. Other minor changes in this patch. - It renames `BitVector::insert()` as `merge()`, which matches the terminology in the other classes in bitvec.rs. - It removes `SparseBitMatrix::is_subset()`, which is unused. - It reinstates `RegionValueElements::num_elements()`, which #52190 had removed. - It removes a low-value `debug!` call in `SparseBitMatrix::add()`.
2018-07-16Generate region values directly to reduce memory usage.David Wood-9/+47
Also modify `SparseBitMatrix` so that it does not require knowing the dimensions in advance, but instead grows on demand.
2018-05-09ignore the point where the outlives requirement was addedNiko Matsakis-1/+1
2018-05-09use chunks api for SparseBitMatrix and add a `subset` fnNiko Matsakis-5/+32
2018-03-20Implement some trivial size_hints for various iteratorsPhlosioneer-0/+5
This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708.
2018-02-22Run rustfmt over bitvec.rs and region_infer/values.rsSantiago Pastorino-32/+44
2018-02-22Fix typo otherwies -> otherwiseSantiago Pastorino-1/+1
2018-02-22Use Sparse bitsets instead of dense ones for NLL resultsSantiago Pastorino-0/+197
Fixes #48170
2018-02-22Move word type and word size usage to constants & make it of 128 bitsSantiago Pastorino-23/+26
2018-01-26Make region inference use a dirty listSantiago Pastorino-0/+11
Fixes #47602
2017-11-02add/fix various comments to `BitMatrix`Niko Matsakis-15/+21
Notably, the (hitherto unused) `less_than` method was not at all what it purported to be. It in fact computes the opposite.
2017-09-24Point at parameter type on E0301Esteban Küber-1/+1
On "the parameter type `T` may not live long enough" error, point to the parameter type suggesting lifetime bindings: ``` error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 27 | struct Foo<T> { | - help: consider adding an explicit lifetime bound `T: 'static`... 28 | foo: &'static T | ^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'static T` does not outlive the data it points at --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 28 | foo: &'static T | ^^^^^^^^^^^^^^^ ```
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-1/+1
Like #43008 (f668999), but _much more aggressive_.
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-1/+1
2017-02-10SwitchInt over SwitchSimonas Kazlauskas-0/+4
This removes another special case of Switch by replacing it with the more general SwitchInt. While this is more clunky currently, there’s no reason we can’t make it nice (and efficient) to use.
2017-01-12Mark some BitVector methods with #[inline]Michael Woerister-0/+9
2016-08-09generalize BitMatrix to be NxM and not just NxNNiko Matsakis-16/+67
2016-08-09isolate predecessor computationNiko Matsakis-0/+6
The new `Predecessors` type computes a set of interesting targets and their HIR predecessors, and discards everything in between.
2016-06-11remove redundant test caseSrinivas Reddy Thatiparthy-15/+1
2016-06-01switch to BitVector, simplify target_block logicScott A Carr-1/+1
clarify comments and panic message
2016-04-28Make the codegen unit partitioner also emit item declarations.Michael Woerister-11/+22
2016-04-03Use a BitVector instead of Vec<bool> for recording cleanup blocksJames Miller-1/+26
Also adds a FromIterator impl for BitVector to allow construction of a BitVector from an iterator yeilding bools.
2016-03-30Add some standard traversal iterators for MIRJames Miller-0/+1
Adds Preorder, Postorder and Reverse Postorder traversal iterators. Also makes trans/mir use Reverse Postorder traversal for blocks.
2016-03-05apply rustfmt to librustc_data_structures, correcting ↵Niko Matsakis-15/+21
rust-lang-nursery/rustfmt#836
2016-02-23[MIR] Change SimplifyCfg pass to use bitvecSimonas Kazlauskas-0/+79
BitVector is much more space efficient.
2016-01-21[MIR] Promote temps to alloca on multi-assignmentSimonas Kazlauskas-2/+4
Fixes #31002
2015-08-21nits from pnkfelixNiko Matsakis-23/+30
2015-08-18generalize bitvector code into a bitmatrix; write some unit tests, butNiko Matsakis-9/+176
probably not enough. This code is so simple, what could possibly go wrong?
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-3/+1
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-04-17Add licenses.Niko Matsakis-0/+10
2015-04-17Port to using the newer graph, which offers iterators instead of theNiko Matsakis-0/+32
older `each` method, but is otherwise identical.