]> git.lizzy.rs Git - rust.git/commitdiff
Use `ArrayVec` in `SparseBitSet`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 14 Jul 2020 00:31:54 +0000 (10:31 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Tue, 14 Jul 2020 00:31:54 +0000 (10:31 +1000)
Instead of `SmallVec`, because the maximum size is known.

Cargo.lock
src/librustc_index/Cargo.toml
src/librustc_index/bit_set.rs

index 905f523aa53d666f67571b835d419e68ba8991bb..9431a5004403f28b8f0e1f7c4fbb0bfc61b09e85 100644 (file)
@@ -94,6 +94,12 @@ dependencies = [
  "nodrop",
 ]
 
+[[package]]
+name = "arrayvec"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
+
 [[package]]
 name = "atty"
 version = "0.2.14"
@@ -164,7 +170,7 @@ version = "0.2.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
 dependencies = [
- "arrayvec",
+ "arrayvec 0.4.7",
  "constant_time_eq",
 ]
 
@@ -714,7 +720,7 @@ version = "0.7.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"
 dependencies = [
- "arrayvec",
+ "arrayvec 0.4.7",
  "cfg-if",
  "crossbeam-utils 0.6.5",
  "lazy_static",
@@ -3494,8 +3500,8 @@ dependencies = [
 name = "rustc_index"
 version = "0.0.0"
 dependencies = [
+ "arrayvec 0.5.1",
  "rustc_serialize",
- "smallvec 1.4.0",
 ]
 
 [[package]]
index f0422b1af1b973618979affefc8cc3fb04561021..00b23760182a229510d25480298bc0abd9ca292f 100644 (file)
@@ -11,4 +11,4 @@ doctest = false
 
 [dependencies]
 rustc_serialize = { path = "../librustc_serialize" }
-smallvec = { version = "1.0", features = ["union", "may_dangle"] }
+arrayvec = "0.5.1"
index cb8b30830c5dec905b7b672804bf1d6837a9b043..3e1d4b68c6fa104f1184d1908c8740009174ceaf 100644 (file)
@@ -1,5 +1,5 @@
 use crate::vec::{Idx, IndexVec};
-use smallvec::SmallVec;
+use arrayvec::ArrayVec;
 use std::fmt;
 use std::iter;
 use std::marker::PhantomData;
@@ -355,20 +355,19 @@ fn bitwise<Op>(out_vec: &mut [Word], in_vec: &[Word], op: Op) -> bool
 const SPARSE_MAX: usize = 8;
 
 /// A fixed-size bitset type with a sparse representation and a maximum of
-/// `SPARSE_MAX` elements. The elements are stored as a sorted `SmallVec` with
-/// no duplicates; although `SmallVec` can spill its elements to the heap, that
-/// never happens within this type because of the `SPARSE_MAX` limit.
+/// `SPARSE_MAX` elements. The elements are stored as a sorted `ArrayVec` with
+/// no duplicates.
 ///
 /// This type is used by `HybridBitSet`; do not use directly.
 #[derive(Clone, Debug)]
 pub struct SparseBitSet<T: Idx> {
     domain_size: usize,
-    elems: SmallVec<[T; SPARSE_MAX]>,
+    elems: ArrayVec<[T; SPARSE_MAX]>,
 }
 
 impl<T: Idx> SparseBitSet<T> {
     fn new_empty(domain_size: usize) -> Self {
-        SparseBitSet { domain_size, elems: SmallVec::new() }
+        SparseBitSet { domain_size, elems: ArrayVec::new() }
     }
 
     fn len(&self) -> usize {