From c4110afc7fe107be62cdea848f0f4a85f9207590 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Sat, 7 Sep 2024 02:33:27 +0200 Subject: [PATCH] [wgpu-core] inline `Storage.insert_impl()` --- wgpu-core/src/storage.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/wgpu-core/src/storage.rs b/wgpu-core/src/storage.rs index b5a2ea129..5a57782bf 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) {