Skip to content

Commit

Permalink
Add Archetype::component_count (#12119)
Browse files Browse the repository at this point in the history
Add Archetype::component_count utility method

# Objective

I wanted a method to count components on an archetype without iterating
over them.

## Solution

Added `Archetype::component_count`

---------

Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
AxiomaticSemantics and alice-i-cecile authored Feb 26, 2024
1 parent c4caebb commit e0e9794
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@ impl Archetype {
self.components.indices()
}

/// Returns the total number of components in the archetype
#[inline]
pub fn component_count(&self) -> usize {
self.components.len()
}

/// Fetches a immutable reference to the archetype's [`Edges`], a cache of
/// archetypal relationships.
#[inline]
Expand Down

0 comments on commit e0e9794

Please sign in to comment.