mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[wgpu-core] inline Storage.insert_impl()
This commit is contained in:
parent
2addb267fc
commit
c4110afc7f
@ -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!(
|
||||
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user