From a99489fb5751a00332de0aceacf3c51dcddfc8b1 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 20 May 2022 22:54:51 +0200 Subject: [PATCH] implement get_rank_set_mark natively --- compiler/types/src/subs.rs | 6 +----- compiler/types/src/unification_table.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 6c00cb1780..8ec808013c 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -1716,11 +1716,7 @@ impl Subs { #[inline(always)] pub fn get_rank_set_mark(&mut self, key: Variable, mark: Mark) -> Rank { - // let l_key = self.utable.inlined_get_root_key(key); - - self.utable.set_mark(key, mark); - - self.utable.get_rank(key) + self.utable.get_rank_set_mark(key, mark) } pub fn equivalent(&mut self, left: Variable, right: Variable) -> bool { diff --git a/compiler/types/src/unification_table.rs b/compiler/types/src/unification_table.rs index 418c74616f..aec0e96bb0 100644 --- a/compiler/types/src/unification_table.rs +++ b/compiler/types/src/unification_table.rs @@ -200,6 +200,16 @@ impl UnificationTable { self.root_key(a) == self.root_key(b) } + // custom very specific helpers + #[inline(always)] + pub fn get_rank_set_mark(&mut self, key: Variable, mark: Mark) -> Rank { + let index = self.root_key(key).index() as usize; + + self.marks[index] = mark; + + self.ranks[index] + } + // TODO remove #[inline(always)] pub fn inlined_get_root_key(&mut self, key: Variable) -> Variable {