diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 9ed0ef6ad1..2e67972fc8 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -104,6 +104,28 @@ impl Assets { self.assets.remove(&handle) } + /// Clears the inner asset map, removing all key-value pairs. + /// + /// Keeps the allocated memory for reuse. + pub fn clear(&mut self) { + self.assets.clear() + } + + /// Reserves capacity for at least additional more elements to be inserted into the assets. + /// + /// The collection may reserve more space to avoid frequent reallocations. + pub fn reserve(&mut self, additional: usize) { + self.assets.reserve(additional) + } + + /// Shrinks the capacity of the asset map as much as possible. + /// + /// It will drop down as much as possible while maintaining the internal rules and possibly + /// leaving some space in accordance with the resize policy. + pub fn shrink_to_fit(&mut self) { + self.assets.shrink_to_fit() + } + pub fn asset_event_system( mut events: ResMut>>, mut assets: ResMut>,