Skip to content

Commit

Permalink
remove extra read() call
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSWard committed Jun 7, 2021
1 parent a6b9506 commit 5730fad
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,11 @@ impl AssetServer {
.detach();

let handle_id = asset_path.get_id().into();

// check if the `handle_id` exists first to avoid unnecessary `write()` calls.
if !self.server.handle_to_path.read().contains_key(&handle_id) {
self.server
.handle_to_path
.write()
.insert(handle_id, asset_path.to_owned());
}
self.server
.handle_to_path
.write()
.entry(handle_id)
.or_insert_with(|| asset_path.to_owned());

asset_path.into()
}
Expand Down

0 comments on commit 5730fad

Please sign in to comment.