Skip to content

Commit

Permalink
use Vec instead of VecDeque
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Dec 10, 2024
1 parent 5d1c3e0 commit f49946a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 4 additions & 10 deletions naga/src/front/atomic_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
//! [`Struct`]: TypeInner::Struct
//! [`Load`]: crate::Expression::Load
//! [`Store`]: crate::Statement::Store
use std::{
collections::VecDeque,
sync::{atomic::AtomicUsize, Arc},
};
use std::sync::{atomic::AtomicUsize, Arc};

use crate::{GlobalVariable, Handle, Module, Type, TypeInner};

Expand Down Expand Up @@ -90,7 +87,7 @@ impl Padding {

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Hash)]
pub struct ContainedGlobalVariable {
pub field_indices: VecDeque<u32>,
pub field_indices: Vec<u32>,
pub handle: Handle<GlobalVariable>,
}

Expand All @@ -109,7 +106,7 @@ impl UpgradeState<'_> {
fn upgrade_type(
&mut self,
ty: Handle<Type>,
field_indices: &mut VecDeque<u32>,
field_indices: &mut Vec<u32>,
) -> Result<Handle<Type>, Error> {
let padding = self.inc_padding();
padding.trace("visiting type: ", ty);
Expand All @@ -129,10 +126,7 @@ impl UpgradeState<'_> {
stride,
},
TypeInner::Struct { ref members, span } => {
let index = field_indices
.pop_back()
.ok_or(Error::UnexpectedEndOfIndices)?;

let index = field_indices.pop().ok_or(Error::UnexpectedEndOfIndices)?;
let mut new_members = vec![];
for (i, mut member) in members.clone().into_iter().enumerate() {
if i == index as usize {
Expand Down
6 changes: 3 additions & 3 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use crate::{
};

use petgraph::graphmap::GraphMap;
use std::{collections::VecDeque, convert::TryInto, mem, num::NonZeroU32, path::PathBuf};
use std::{convert::TryInto, mem, num::NonZeroU32, path::PathBuf};

use super::atomic_upgrade::ContainedGlobalVariable;

Expand Down Expand Up @@ -573,7 +573,7 @@ impl BlockContext<'_> {
mut handle: Handle<crate::Expression>,
) -> Result<ContainedGlobalVariable, Error> {
log::debug!("\t\tlocating global variable in {handle:?}");
let mut accesses = VecDeque::default();
let mut accesses = vec![];
loop {
match self.expressions[handle] {
crate::Expression::Access { base, index } => {
Expand All @@ -582,7 +582,7 @@ impl BlockContext<'_> {
}
crate::Expression::AccessIndex { base, index } => {
handle = base;
accesses.push_back(index);
accesses.push(index);
log::debug!("\t\t access index {handle:?} {index:?}");
}
crate::Expression::GlobalVariable(h) => {
Expand Down

0 comments on commit f49946a

Please sign in to comment.