Skip to content

Commit

Permalink
[wgpu-core] inline Storage.insert_impl()
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Sep 10, 2024
1 parent 2addb26 commit c4110af
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions wgpu-core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ impl<T> Storage<T>
where
T: StorageItem,
{
fn insert_impl(&mut self, index: usize, epoch: Epoch, element: Element<T>) {
pub(crate) fn insert(&mut self, id: Id<T::Marker>, 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!(
Expand All @@ -91,11 +93,6 @@ where
}
}

pub(crate) fn insert(&mut self, id: Id<T::Marker>, 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::Marker>) -> T {
let (index, epoch, _) = id.unzip();
match std::mem::replace(&mut self.map[index as usize], Element::Vacant) {
Expand Down

0 comments on commit c4110af

Please sign in to comment.