Skip to content

Commit bd81fc8

Browse files
committed
Inline (Partial)Ord/Eq and Hash impls
1 parent ca75318 commit bd81fc8

File tree

1 file changed

+5
-0
lines changed
  • crates/bevy_ecs/src/entity

1 file changed

+5
-0
lines changed

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl Entity {
123123
/// for serialization between runs.
124124
///
125125
/// No particular structure is guaranteed for the returned bits.
126+
#[inline(always)]
126127
pub fn to_bits(self) -> u64 {
127128
u64::from(self.generation) << 32 | u64::from(self.id)
128129
}
@@ -158,25 +159,29 @@ impl Entity {
158159

159160
// Required for ordering correctness. Cannot be done with a derive macro.
160161
impl PartialOrd for Entity {
162+
#[inline]
161163
fn partial_cmp(&self, other: &Self) -> Option<CmpOrdering> {
162164
Some(self.to_bits().cmp(&other.to_bits()))
163165
}
164166
}
165167

166168
// Required for ordering correctness. Cannot be done with a derive macro.
167169
impl Ord for Entity {
170+
#[inline]
168171
fn cmp(&self, other: &Self) -> CmpOrdering {
169172
self.to_bits().cmp(&other.to_bits())
170173
}
171174
}
172175

173176
impl Hash for Entity {
177+
#[inline]
174178
fn hash<H: Hasher>(&self, hasher: &mut H) {
175179
self.to_bits().hash(hasher)
176180
}
177181
}
178182

179183
impl PartialEq for Entity {
184+
#[inline]
180185
fn eq(&self, other: &Self) -> bool {
181186
self.to_bits() == other.to_bits()
182187
}

0 commit comments

Comments
 (0)