LayoutIds use LayoutRepr

This commit is contained in:
Ayaz Hafiz 2023-06-16 22:00:02 -05:00
parent 94e97df54a
commit ee25735731
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
5 changed files with 21 additions and 26 deletions

View file

@ -4451,14 +4451,14 @@ impl LayoutId {
}
struct IdsByLayout<'a> {
by_id: MutMap<InLayout<'a>, u32>,
by_id: MutMap<LayoutRepr<'a>, u32>,
toplevels_by_id: MutMap<crate::ir::ProcLayout<'a>, u32>,
next_id: u32,
}
impl<'a> IdsByLayout<'a> {
#[inline(always)]
fn insert_layout(&mut self, layout: InLayout<'a>) -> LayoutId {
fn insert_layout(&mut self, layout: LayoutRepr<'a>) -> LayoutId {
match self.by_id.entry(layout) {
Entry::Vacant(vacant) => {
let answer = self.next_id;
@ -4472,7 +4472,7 @@ impl<'a> IdsByLayout<'a> {
}
#[inline(always)]
fn singleton_layout(layout: InLayout<'a>) -> (Self, LayoutId) {
fn singleton_layout(layout: LayoutRepr<'a>) -> (Self, LayoutId) {
let mut by_id = HashMap::with_capacity_and_hasher(1, default_hasher());
by_id.insert(layout, 1);
@ -4523,7 +4523,7 @@ impl<'a> LayoutIds<'a> {
/// Returns a LayoutId which is unique for the given symbol and layout.
/// If given the same symbol and same layout, returns the same LayoutId.
#[inline(always)]
pub fn get<'b>(&mut self, symbol: Symbol, layout: &'b InLayout<'a>) -> LayoutId {
pub fn get<'b>(&mut self, symbol: Symbol, layout: &'b LayoutRepr<'a>) -> LayoutId {
match self.by_symbol.entry(symbol) {
Entry::Vacant(vacant) => {
let (ids_by_layout, layout_id) = IdsByLayout::singleton_layout(*layout);