about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorValerii Lashmanov <vflashm@gmail.com>2020-09-23 23:32:11 -0500
committerValerii Lashmanov <vflashm@gmail.com>2020-09-26 14:30:05 -0500
commit5c224a484dc6ba2a70c9cd0d73a04849f6d7aa68 (patch)
tree16919ad7dbdbb6ba195ac59da944d37d93bb6c18 /compiler/rustc_data_structures/src
parent6f9a8a7f9b9732c55511d2a2a3914e8feafc7c52 (diff)
downloadrust-5c224a484dc6ba2a70c9cd0d73a04849f6d7aa68.tar.gz
rust-5c224a484dc6ba2a70c9cd0d73a04849f6d7aa68.zip
MiniSet/MiniMap moved and renamed into SsoHashSet/SsoHashMap
It is a more descriptive name and with upcoming changes
there will be nothing "mini" about them.
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/lib.rs3
-rw-r--r--compiler/rustc_data_structures/src/sso/map.rs (renamed from compiler/rustc_data_structures/src/mini_map.rs)18
-rw-r--r--compiler/rustc_data_structures/src/sso/mod.rs5
-rw-r--r--compiler/rustc_data_structures/src/sso/set.rs (renamed from compiler/rustc_data_structures/src/mini_set.rs)14
4 files changed, 22 insertions, 18 deletions
diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs
index 9ded10e9c26..d0f2a4148d3 100644
--- a/compiler/rustc_data_structures/src/lib.rs
+++ b/compiler/rustc_data_structures/src/lib.rs
@@ -101,8 +101,7 @@ pub mod vec_linked_list;
 pub mod work_queue;
 pub use atomic_ref::AtomicRef;
 pub mod frozen;
-pub mod mini_map;
-pub mod mini_set;
+pub mod sso;
 pub mod tagged_ptr;
 pub mod temp_dir;
 pub mod unhash;
diff --git a/compiler/rustc_data_structures/src/mini_map.rs b/compiler/rustc_data_structures/src/sso/map.rs
index cd3e949d383..c253e9d6616 100644
--- a/compiler/rustc_data_structures/src/mini_map.rs
+++ b/compiler/rustc_data_structures/src/sso/map.rs
@@ -8,21 +8,21 @@ use std::hash::Hash;
 ///
 /// Stores elements in a small array up to a certain length
 /// and switches to `HashMap` when that length is exceeded.
-pub enum MiniMap<K, V> {
+pub enum SsoHashMap<K, V> {
     Array(ArrayVec<[(K, V); 8]>),
     Map(FxHashMap<K, V>),
 }
 
-impl<K: Eq + Hash, V> MiniMap<K, V> {
-    /// Creates an empty `MiniMap`.
+impl<K: Eq + Hash, V> SsoHashMap<K, V> {
+    /// Creates an empty `SsoHashMap`.
     pub fn new() -> Self {
-        MiniMap::Array(ArrayVec::new())
+        SsoHashMap::Array(ArrayVec::new())
     }
 
     /// Inserts or updates value in the map.
     pub fn insert(&mut self, key: K, value: V) {
         match self {
-            MiniMap::Array(array) => {
+            SsoHashMap::Array(array) => {
                 for pair in array.iter_mut() {
                     if pair.0 == key {
                         pair.1 = value;
@@ -33,10 +33,10 @@ impl<K: Eq + Hash, V> MiniMap<K, V> {
                     let mut map: FxHashMap<K, V> = array.drain(..).collect();
                     let (key, value) = error.element();
                     map.insert(key, value);
-                    *self = MiniMap::Map(map);
+                    *self = SsoHashMap::Map(map);
                 }
             }
-            MiniMap::Map(map) => {
+            SsoHashMap::Map(map) => {
                 map.insert(key, value);
             }
         }
@@ -45,7 +45,7 @@ impl<K: Eq + Hash, V> MiniMap<K, V> {
     /// Return value by key if any.
     pub fn get(&self, key: &K) -> Option<&V> {
         match self {
-            MiniMap::Array(array) => {
+            SsoHashMap::Array(array) => {
                 for pair in array {
                     if pair.0 == *key {
                         return Some(&pair.1);
@@ -53,7 +53,7 @@ impl<K: Eq + Hash, V> MiniMap<K, V> {
                 }
                 return None;
             }
-            MiniMap::Map(map) => {
+            SsoHashMap::Map(map) => {
                 return map.get(key);
             }
         }
diff --git a/compiler/rustc_data_structures/src/sso/mod.rs b/compiler/rustc_data_structures/src/sso/mod.rs
new file mode 100644
index 00000000000..ef634b9adce
--- /dev/null
+++ b/compiler/rustc_data_structures/src/sso/mod.rs
@@ -0,0 +1,5 @@
+mod map;
+mod set;
+
+pub use map::SsoHashMap;
+pub use set::SsoHashSet;
diff --git a/compiler/rustc_data_structures/src/mini_set.rs b/compiler/rustc_data_structures/src/sso/set.rs
index 9d45af723de..b403c9dcc33 100644
--- a/compiler/rustc_data_structures/src/mini_set.rs
+++ b/compiler/rustc_data_structures/src/sso/set.rs
@@ -5,15 +5,15 @@ use std::hash::Hash;
 ///
 /// Stores elements in a small array up to a certain length
 /// and switches to `HashSet` when that length is exceeded.
-pub enum MiniSet<T> {
+pub enum SsoHashSet<T> {
     Array(ArrayVec<[T; 8]>),
     Set(FxHashSet<T>),
 }
 
-impl<T: Eq + Hash> MiniSet<T> {
-    /// Creates an empty `MiniSet`.
+impl<T: Eq + Hash> SsoHashSet<T> {
+    /// Creates an empty `SsoHashSet`.
     pub fn new() -> Self {
-        MiniSet::Array(ArrayVec::new())
+        SsoHashSet::Array(ArrayVec::new())
     }
 
     /// Adds a value to the set.
@@ -23,19 +23,19 @@ impl<T: Eq + Hash> MiniSet<T> {
     /// If the set did have this value present, false is returned.
     pub fn insert(&mut self, elem: T) -> bool {
         match self {
-            MiniSet::Array(array) => {
+            SsoHashSet::Array(array) => {
                 if array.iter().any(|e| *e == elem) {
                     false
                 } else {
                     if let Err(error) = array.try_push(elem) {
                         let mut set: FxHashSet<T> = array.drain(..).collect();
                         set.insert(error.element());
-                        *self = MiniSet::Set(set);
+                        *self = SsoHashSet::Set(set);
                     }
                     true
                 }
             }
-            MiniSet::Set(set) => set.insert(elem),
+            SsoHashSet::Set(set) => set.insert(elem),
         }
     }
 }