Skip to content

Commit

Permalink
perf(check): No need to lookup the type again before querying the level
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Aug 31, 2019
1 parent 03e7c3b commit 5e4efe3
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions check/src/substitution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,21 +413,13 @@ where
}

/// Updates the level of `other` to be the minimum level value of `var` and `other`
pub fn update_level(&self, var: u32, other: u32) {
fn update_level(&self, var: u32, other: u32) {
let level = ::std::cmp::min(self.get_level(var), self.get_level(other));
let mut union = self.union.borrow_mut();
union.union_value(other, Level(level));
}

pub fn set_level(&self, var: u32, level: u32) {
let mut union = self.union.borrow_mut();
union.union_value(var, Level(level));
}

pub fn get_level(&self, mut var: u32) -> u32 {
if let Some(v) = self.find_type_for_var(var) {
var = v.get_var().map_or(var, |v| v.get_id());
}
pub fn get_level(&self, var: u32) -> u32 {
let mut union = self.union.borrow_mut();
union.union_value(var, Level(var));
union.probe_value(var).0
Expand Down

0 comments on commit 5e4efe3

Please sign in to comment.