diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_index/src/bit_set.rs | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_index/src/bit_set.rs')
-rw-r--r-- | compiler/rustc_index/src/bit_set.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index cbf169afb..271ab8306 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -1,5 +1,6 @@ use crate::vec::{Idx, IndexVec}; use arrayvec::ArrayVec; +use smallvec::{smallvec, SmallVec}; use std::fmt; use std::iter; use std::marker::PhantomData; @@ -111,7 +112,7 @@ macro_rules! bit_relations_inherent_impls { #[derive(Eq, PartialEq, Hash, Decodable, Encodable)] pub struct BitSet<T> { domain_size: usize, - words: Vec<Word>, + words: SmallVec<[Word; 2]>, marker: PhantomData<T>, } @@ -127,14 +128,15 @@ impl<T: Idx> BitSet<T> { #[inline] pub fn new_empty(domain_size: usize) -> BitSet<T> { let num_words = num_words(domain_size); - BitSet { domain_size, words: vec![0; num_words], marker: PhantomData } + BitSet { domain_size, words: smallvec![0; num_words], marker: PhantomData } } /// Creates a new, filled bitset with a given `domain_size`. #[inline] pub fn new_filled(domain_size: usize) -> BitSet<T> { let num_words = num_words(domain_size); - let mut result = BitSet { domain_size, words: vec![!0; num_words], marker: PhantomData }; + let mut result = + BitSet { domain_size, words: smallvec![!0; num_words], marker: PhantomData }; result.clear_excess_bits(); result } @@ -1571,7 +1573,7 @@ impl<T: Idx> From<BitSet<T>> for GrowableBitSet<T> { pub struct BitMatrix<R: Idx, C: Idx> { num_rows: usize, num_columns: usize, - words: Vec<Word>, + words: SmallVec<[Word; 2]>, marker: PhantomData<(R, C)>, } @@ -1584,7 +1586,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> { BitMatrix { num_rows, num_columns, - words: vec![0; num_rows * words_per_row], + words: smallvec![0; num_rows * words_per_row], marker: PhantomData, } } @@ -1848,7 +1850,7 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> { /// Iterates through all the columns set to true in a given row of /// the matrix. - pub fn iter<'a>(&'a self, row: R) -> impl Iterator<Item = C> + 'a { + pub fn iter(&self, row: R) -> impl Iterator<Item = C> + '_ { self.row(row).into_iter().flat_map(|r| r.iter()) } |