Replace SSABuilder's variables HashMaps with EntityMaps. (#150)

* Replace SSABuilder's variables HashMaps with EntityMaps.

Current measurements show that memory usage is approximately the same,
and it's about 20% faster.

* Add EntityMap::with_default and use it.

* rustfmt

* Use var_defs[block].expand().
This commit is contained in:
Dan Gohman
2017-09-02 04:11:51 -07:00
committed by GitHub
parent 03939e4f9f
commit 9ea40ad44a
2 changed files with 19 additions and 8 deletions

View File

@@ -41,6 +41,17 @@ where
}
}
/// Create a new empty map with a specified default value.
///
/// This constructor does not require V to implement Default.
pub fn with_default(default: V) -> Self {
EntityMap {
elems: Vec::new(),
default: default,
unused: PhantomData,
}
}
/// Get the element at `k` if it exists.
pub fn get(&self, k: K) -> Option<&V> {
self.elems.get(k.index())