Skip to content

Commit

Permalink
feat: Add take method to Arena
Browse files Browse the repository at this point in the history
Add take method to Arena to avoid unnecessary cloning.
  • Loading branch information
junjunjd committed Feb 18, 2025
1 parent 9da04c2 commit b2c57f6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ By @cwfitzgerald in [#7030](https://github.com/gfx-rs/wgpu/pull/7030).
- Support @must_use attribute on function declarations. By @turbocrime in [#6801](https://github.com/gfx-rs/wgpu/pull/6801).
- Support for generating the candidate intersections from AABB geometry, and confirming the hits. By @kvark in [#7047](https://github.com/gfx-rs/wgpu/pull/7047).
- Make naga::back::spv::Function::to_words write the OpFunctionEnd instruction in itself, instead of making another call after it. By @junjunjd in [#7156](https://github.com/gfx-rs/wgpu/pull/7156).
- Use take method for Arena to avoid unnecessary cloning. By @junjunjd in [#7176](https://github.com/gfx-rs/wgpu/pull/7176).
### Changes
Expand Down
4 changes: 2 additions & 2 deletions naga/src/front/wgsl/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {

pub fn lower(
&mut self,
tu: &'temp ast::TranslationUnit<'source>,
tu: &'temp mut ast::TranslationUnit<'source>,
) -> Result<crate::Module, Error<'source>> {
let mut module = crate::Module {
diagnostic_filters: tu.diagnostic_filters.clone(),
diagnostic_filters: std::mem::take(&mut tu.diagnostic_filters),
diagnostic_filter_leaf: tu.diagnostic_filter_leaf,
..Default::default()
};
Expand Down
4 changes: 2 additions & 2 deletions naga/src/front/wgsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl Frontend {
}

fn inner<'a>(&mut self, source: &'a str) -> Result<crate::Module, Error<'a>> {
let tu = self.parser.parse(source)?;
let mut tu = self.parser.parse(source)?;
let index = index::Index::generate(&tu)?;
let module = Lowerer::new(&index).lower(&tu)?;
let module = Lowerer::new(&index).lower(&mut tu)?;

Ok(module)
}
Expand Down

0 comments on commit b2c57f6

Please sign in to comment.