diff --git a/naga/src/proc/layouter.rs b/naga/src/proc/layouter.rs index 1c78a594d1..82b1be094a 100644 --- a/naga/src/proc/layouter.rs +++ b/naga/src/proc/layouter.rs @@ -1,4 +1,4 @@ -use crate::arena::Handle; +use crate::arena::{Handle, HandleVec}; use std::{fmt::Display, num::NonZeroU32, ops}; /// A newtype struct where its only valid values are powers of 2 @@ -108,17 +108,15 @@ impl TypeLayout { /// /// [WGSL ยง4.3.7, "Memory Layout"](https://gpuweb.github.io/gpuweb/wgsl/#memory-layouts) #[derive(Debug, Default)] -#[cfg_attr(feature = "serialize", derive(serde::Serialize))] -#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] pub struct Layouter { - /// Layouts for types in an arena, indexed by `Handle` index. - layouts: Vec, + /// Layouts for types in an arena. + layouts: HandleVec, } impl ops::Index> for Layouter { type Output = TypeLayout; fn index(&self, handle: Handle) -> &TypeLayout { - &self.layouts[handle.index()] + &self.layouts[handle] } } @@ -243,7 +241,7 @@ impl Layouter { }, }; debug_assert!(size <= layout.size); - self.layouts.push(layout); + self.layouts.insert(ty_handle, layout); } Ok(())