about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-26 10:04:42 +0000
committerbors <bors@rust-lang.org>2018-09-26 10:04:42 +0000
commitc3a1a0d3400bbbcac194efb6ef2b14eef9be5149 (patch)
tree0a75f20d6c5a9def5008fd24194e83946f9ac9db /src/librustc_data_structures
parenta2b27c19dad8b90063b56eff7b6433ba3f390d96 (diff)
parent130a32fa7259d348dc3a684b38e688da398c30bb (diff)
Auto merge of #53824 - ljedrz:begone_onevector, r=michaelwoerister
Remove OneVector, increase related SmallVec capacities

Removes the `OneVector` type alias (equivalent to `SmallVec<[T; 1]>`); it is used in scenarios where the capacity of 1 is often exceeded, which might be nullifying the performance wins (due to spilling to the heap) expected when using `SmallVec` instead of `Vec`.

The numbers I used in this PR are very rough estimates - it would probably be a good idea to adjust some/all of them, which is what this proposal is all about.

It might be a good idea to additionally create some local type aliases for the `SmallVec`s in the `Folder` trait, as they are repeated in quite a few spots; I'd be happy to apply this sort of adjustments.
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/lib.rs2
-rw-r--r--src/librustc_data_structures/small_vec.rs55
2 files changed, 0 insertions, 57 deletions
diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs
index 70b960ac351..43ab3869806 100644
--- a/src/librustc_data_structures/lib.rs
+++ b/src/librustc_data_structures/lib.rs
@@ -50,7 +50,6 @@ extern crate rustc_rayon as rayon;
 extern crate rustc_rayon_core as rayon_core;
 extern crate rustc_hash;
 extern crate serialize;
-#[cfg_attr(test, macro_use)]
 extern crate smallvec;
 
 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
@@ -72,7 +71,6 @@ pub mod owning_ref;
 pub mod ptr_key;
 pub mod sip128;
 pub mod small_c_str;
-pub mod small_vec;
 pub mod snapshot_map;
 pub use ena::snapshot_vec;
 pub mod sorted_map;
diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs
deleted file mode 100644
index 075b70c6426..00000000000
--- a/src/librustc_data_structures/small_vec.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A vector type intended to be used for small vectors.
-//!
-//! Space for up to N elements is provided on the stack. If more elements are collected, Vec is
-//! used to store the values on the heap.
-//!
-//! The N above is determined by Array's implementor, by way of an associated constant.
-
-use smallvec::{Array, SmallVec};
-
-pub type OneVector<T> = SmallVec<[T; 1]>;
-
-pub trait ExpectOne<A: Array> {
-    fn expect_one(self, err: &'static str) -> A::Item;
-}
-
-impl<A: Array> ExpectOne<A> for SmallVec<A> {
-    fn expect_one(self, err: &'static str) -> A::Item {
-        assert!(self.len() == 1, err);
-        self.into_iter().next().unwrap()
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    extern crate test;
-    use super::*;
-
-    #[test]
-    #[should_panic]
-    fn test_expect_one_zero() {
-        let _: isize = OneVector::new().expect_one("");
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_expect_one_many() {
-        OneVector::from_vec(vec![1, 2]).expect_one("");
-    }
-
-    #[test]
-    fn test_expect_one_one() {
-        assert_eq!(1, (smallvec![1] as OneVector<_>).expect_one(""));
-        assert_eq!(1, OneVector::from_vec(vec![1]).expect_one(""));
-    }
-}