Skip to content

Commit 99c0b97

Browse files
authoredJul 14, 2020
Rollup merge of rust-lang#74310 - nnethercote:use-ArrayVec-in-SparseBitSet, r=eddyb
Use `ArrayVec` in `SparseBitSet`. Instead of `SmallVec`, because the maximum size is known. r? @eddyb
2 parents e8703e8 + c492ca4 commit 99c0b97

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed
 

‎Cargo.lock

+9-3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ dependencies = [
9494
"nodrop",
9595
]
9696

97+
[[package]]
98+
name = "arrayvec"
99+
version = "0.5.1"
100+
source = "registry+https://github.com/rust-lang/crates.io-index"
101+
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
102+
97103
[[package]]
98104
name = "atty"
99105
version = "0.2.14"
@@ -164,7 +170,7 @@ version = "0.2.18"
164170
source = "registry+https://github.com/rust-lang/crates.io-index"
165171
checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
166172
dependencies = [
167-
"arrayvec",
173+
"arrayvec 0.4.7",
168174
"constant_time_eq",
169175
]
170176

@@ -714,7 +720,7 @@ version = "0.7.2"
714720
source = "registry+https://github.com/rust-lang/crates.io-index"
715721
checksum = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"
716722
dependencies = [
717-
"arrayvec",
723+
"arrayvec 0.4.7",
718724
"cfg-if",
719725
"crossbeam-utils 0.6.5",
720726
"lazy_static",
@@ -3494,8 +3500,8 @@ dependencies = [
34943500
name = "rustc_index"
34953501
version = "0.0.0"
34963502
dependencies = [
3503+
"arrayvec 0.5.1",
34973504
"rustc_serialize",
3498-
"smallvec 1.4.0",
34993505
]
35003506

35013507
[[package]]

‎src/librustc_index/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_serialize = { path = "../librustc_serialize" }
14-
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
14+
arrayvec = "0.5.1"

‎src/librustc_index/bit_set.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::vec::{Idx, IndexVec};
2-
use smallvec::SmallVec;
2+
use arrayvec::ArrayVec;
33
use std::fmt;
44
use std::iter;
55
use std::marker::PhantomData;
@@ -355,20 +355,19 @@ where
355355
const SPARSE_MAX: usize = 8;
356356

357357
/// A fixed-size bitset type with a sparse representation and a maximum of
358-
/// `SPARSE_MAX` elements. The elements are stored as a sorted `SmallVec` with
359-
/// no duplicates; although `SmallVec` can spill its elements to the heap, that
360-
/// never happens within this type because of the `SPARSE_MAX` limit.
358+
/// `SPARSE_MAX` elements. The elements are stored as a sorted `ArrayVec` with
359+
/// no duplicates.
361360
///
362361
/// This type is used by `HybridBitSet`; do not use directly.
363362
#[derive(Clone, Debug)]
364363
pub struct SparseBitSet<T: Idx> {
365364
domain_size: usize,
366-
elems: SmallVec<[T; SPARSE_MAX]>,
365+
elems: ArrayVec<[T; SPARSE_MAX]>,
367366
}
368367

369368
impl<T: Idx> SparseBitSet<T> {
370369
fn new_empty(domain_size: usize) -> Self {
371-
SparseBitSet { domain_size, elems: SmallVec::new() }
370+
SparseBitSet { domain_size, elems: ArrayVec::new() }
372371
}
373372

374373
fn len(&self) -> usize {

0 commit comments

Comments
 (0)
Please sign in to comment.