Skip to content

Commit

Permalink
Remove unnecessary mutability from ResourceMetadata field uses. (#3210)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy authored Nov 15, 2022
1 parent 18f3f5f commit f41a1c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions wgpu-core/src/track/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ impl<A: hub::HalApi> BufferTracker<A> {

unsafe {
if self.metadata.owned.get(index).unwrap_unchecked() {
let existing_epoch = self.metadata.epochs.get_unchecked_mut(index);
let existing_ref_count = self.metadata.ref_counts.get_unchecked_mut(index);
let existing_epoch = self.metadata.epochs.get_unchecked(index);
let existing_ref_count = self.metadata.ref_counts.get_unchecked(index);

if *existing_epoch == epoch
&& existing_ref_count.as_mut().unwrap_unchecked().load() == 1
&& existing_ref_count.as_ref().unwrap_unchecked().load() == 1
{
self.metadata.reset(index);

Expand Down
6 changes: 3 additions & 3 deletions wgpu-core/src/track/stateless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ impl<A: hub::HalApi, T: hub::Resource, Id: TypedId> StatelessTracker<A, T, Id> {

unsafe {
if self.metadata.owned.get(index).unwrap_unchecked() {
let existing_epoch = self.metadata.epochs.get_unchecked_mut(index);
let existing_ref_count = self.metadata.ref_counts.get_unchecked_mut(index);
let existing_epoch = self.metadata.epochs.get_unchecked(index);
let existing_ref_count = self.metadata.ref_counts.get_unchecked(index);

if *existing_epoch == epoch
&& existing_ref_count.as_mut().unwrap_unchecked().load() == 1
&& existing_ref_count.as_ref().unwrap_unchecked().load() == 1
{
self.metadata.reset(index);

Expand Down
6 changes: 3 additions & 3 deletions wgpu-core/src/track/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,11 @@ impl<A: hub::HalApi> TextureTracker<A> {

unsafe {
if self.metadata.owned.get(index).unwrap_unchecked() {
let existing_epoch = self.metadata.epochs.get_unchecked_mut(index);
let existing_ref_count = self.metadata.ref_counts.get_unchecked_mut(index);
let existing_epoch = self.metadata.epochs.get_unchecked(index);
let existing_ref_count = self.metadata.ref_counts.get_unchecked(index);

if *existing_epoch == epoch
&& existing_ref_count.as_mut().unwrap_unchecked().load() == 1
&& existing_ref_count.as_ref().unwrap_unchecked().load() == 1
{
self.start_set.complex.remove(&index32);
self.end_set.complex.remove(&index32);
Expand Down

0 comments on commit f41a1c2

Please sign in to comment.