rustc_index: Add some map-like APIs to IndexVec

This commit is contained in:
Vadim Petrochenkov
2021-09-22 01:59:46 +03:00
parent ac2d9fc509
commit fbe5e5c0ee
4 changed files with 28 additions and 24 deletions

View File

@@ -1072,13 +1072,9 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
}
fn ensure_row(&mut self, row: R) -> &mut HybridBitSet<C> {
// Instantiate any missing rows up to and including row `row` with an
// empty HybridBitSet.
self.rows.ensure_contains_elem(row, || None);
// Instantiate any missing rows up to and including row `row` with an empty HybridBitSet.
// Then replace row `row` with a full HybridBitSet if necessary.
let num_columns = self.num_columns;
self.rows[row].get_or_insert_with(|| HybridBitSet::new_empty(num_columns))
self.rows.get_or_insert_with(row, || HybridBitSet::new_empty(self.num_columns))
}
/// Sets the cell at `(row, column)` to true. Put another way, insert