Skip to content

Commit

Permalink
[assets] remove unnecessary temporary strong handles (bevyengine#2304)
Browse files Browse the repository at this point in the history
# Objective

- When creating an asset, the `update_asset_storage` function was unnecessarily creating an extraneous `Handle` to the created asset via calling `set`. This has some overhead as the `RefChange::Increment/Decrement` event was being sent.  
- A similar exteraneous handle is also created in `load_async` when loading dependencies. 

## Solution

- Have the implementation use `Assets::set_untracked` and `AssetServer::load_untracked` so no intermediate handle is created.
  • Loading branch information
NathanSWard committed Jun 7, 2021
1 parent 4fed2ee commit 27d809f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ impl AssetServer {
let type_uuid = loaded_asset.value.as_ref().unwrap().type_uuid();
source_info.asset_types.insert(label_id, type_uuid);
for dependency in loaded_asset.dependencies.iter() {
// another handle already exists created from the asset path
let _ = self.load_untyped(dependency.clone());
self.load_untracked(dependency.clone(), false);
}
}

Expand Down Expand Up @@ -493,7 +492,7 @@ impl AssetServer {
}
}

let _ = assets.set(result.id, *result.asset);
assets.set_untracked(result.id, *result.asset);
}
Ok(AssetLifecycleEvent::Free(handle_id)) => {
if let HandleId::AssetPathId(id) = handle_id {
Expand Down

0 comments on commit 27d809f

Please sign in to comment.