diff --git a/wgpu-core/src/storage.rs b/wgpu-core/src/storage.rs index b5a2ea1299..5a57782bf7 100644 --- a/wgpu-core/src/storage.rs +++ b/wgpu-core/src/storage.rs @@ -74,11 +74,13 @@ impl Storage where T: StorageItem, { - fn insert_impl(&mut self, index: usize, epoch: Epoch, element: Element) { + pub(crate) fn insert(&mut self, id: Id, value: T) { + let (index, epoch, _) = id.unzip(); + let index = index as usize; if index >= self.map.len() { self.map.resize_with(index + 1, || Element::Vacant); } - match std::mem::replace(&mut self.map[index], element) { + match std::mem::replace(&mut self.map[index], Element::Occupied(value, epoch)) { Element::Vacant => {} Element::Occupied(_, storage_epoch) => { assert_ne!( @@ -91,11 +93,6 @@ where } } - pub(crate) fn insert(&mut self, id: Id, value: T) { - let (index, epoch, _backend) = id.unzip(); - self.insert_impl(index as usize, epoch, Element::Occupied(value, epoch)) - } - pub(crate) fn remove(&mut self, id: Id) -> T { let (index, epoch, _) = id.unzip(); match std::mem::replace(&mut self.map[index as usize], Element::Vacant) {