Commit 7c12524c authored by Ryan Hunt's avatar Ryan Hunt
Browse files

Use a BTreeMap with monomorphs to improve dependeny order stability

parent 6080032c
......@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::io::Write;
use syn;
......@@ -50,7 +50,7 @@ impl OpaqueItem {
};
if !out.contains_key(&self.name) {
out.insert(self.name.clone(), HashMap::new());
out.insert(self.name.clone(), BTreeMap::new());
}
out.get_mut(&self.name).unwrap().insert(generic_values.clone(),
Monomorph::OpaqueItem(monomorph));
......
......@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::io::Write;
use syn;
......@@ -97,7 +97,7 @@ impl Struct {
}
if !out.contains_key(&self.name) {
out.insert(self.name.clone(), HashMap::new());
out.insert(self.name.clone(), BTreeMap::new());
}
out.get_mut(&self.name).unwrap().insert(generic_values.clone(),
Monomorph::Struct(monomorph));
......
......@@ -13,7 +13,7 @@ use bindgen::library::*;
use bindgen::utilities::*;
use bindgen::writer::*;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum PrimitiveType {
Void,
Bool,
......@@ -158,7 +158,7 @@ impl fmt::Display for PrimitiveType {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Type {
ConstPtr(Box<Type>),
Ptr(Box<Type>),
......
......@@ -120,8 +120,8 @@ impl Monomorph {
}
}
pub type MonomorphList = HashMap<Vec<Type>, Monomorph>;
pub type Monomorphs = HashMap<PathRef, MonomorphList>;
pub type MonomorphList = BTreeMap<Vec<Type>, Monomorph>;
pub type Monomorphs = BTreeMap<PathRef, MonomorphList>;
/// A dependency list is used for gathering what order to output the types.
pub struct DependencyList {
......@@ -708,7 +708,7 @@ impl Library {
// TODO
let mut new_monomorphs = Monomorphs::new();
for (path, monomorph_set) in monomorphs.iter() {
let mut new_monomorph_set = HashMap::new();
let mut new_monomorph_set = BTreeMap::new();
for (generic_values, monomorph) in monomorph_set.iter() {
let mut new_generic_values = generic_values.clone();
for generic_value in &mut new_generic_values {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment