Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions crates/bevy_reflect/src/enums/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use core::{
};

/// Returns the `u64` hash of the given [enum](Enum).
#[inline]
pub fn enum_hash<TEnum: Enum>(value: &TEnum) -> Option<u64> {
#[inline(never)]
pub fn enum_hash(value: &dyn Enum) -> Option<u64> {
let mut hasher = reflect_hasher();
core::any::Any::type_id(value).hash(&mut hasher);
value.variant_name().hash(&mut hasher);
Expand All @@ -29,8 +29,8 @@ pub fn enum_hash<TEnum: Enum>(value: &TEnum) -> Option<u64> {
/// - For each field in `a`, `b` contains a field with the same name and
/// [`PartialReflect::reflect_partial_eq`] returns `Some(true)` for the two field
/// values.
#[inline]
pub fn enum_partial_eq<TEnum: Enum + ?Sized>(a: &TEnum, b: &dyn PartialReflect) -> Option<bool> {
#[inline(never)]
pub fn enum_partial_eq(a: &dyn Enum, b: &dyn PartialReflect) -> Option<bool> {
// Both enums?
let ReflectRef::Enum(b) = b.reflect_ref() else {
return Some(false);
Expand Down Expand Up @@ -94,11 +94,8 @@ pub fn enum_partial_eq<TEnum: Enum + ?Sized>(a: &TEnum, b: &dyn PartialReflect)
/// or an element comparison returns `None`).
///
/// The ordering is same with `derive` macro. First order by variant index, then by fields.
#[inline]
pub fn enum_partial_cmp<TEnum: Enum + ?Sized>(
a: &TEnum,
b: &dyn PartialReflect,
) -> Option<::core::cmp::Ordering> {
#[inline(never)]
pub fn enum_partial_cmp(a: &dyn Enum, b: &dyn PartialReflect) -> Option<::core::cmp::Ordering> {
// Both enums?
let ReflectRef::Enum(b) = b.reflect_ref() else {
return None;
Expand Down
11 changes: 4 additions & 7 deletions crates/bevy_reflect/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ impl<'a> IntoIterator for &'a DynamicStruct {
/// values.
///
/// Returns [`None`] if the comparison couldn't even be performed.
#[inline]
pub fn struct_partial_eq<S: Struct + ?Sized>(a: &S, b: &dyn PartialReflect) -> Option<bool> {
#[inline(never)]
pub fn struct_partial_eq(a: &dyn Struct, b: &dyn PartialReflect) -> Option<bool> {
let ReflectRef::Struct(struct_value) = b.reflect_ref() else {
return Some(false);
};
Expand Down Expand Up @@ -545,11 +545,8 @@ pub fn struct_partial_eq<S: Struct + ?Sized>(a: &S, b: &dyn PartialReflect) -> O
///
/// Returns [`None`] if the comparison couldn't be performed (e.g., kinds mismatch
/// or an element comparison returns `None`).
#[inline]
pub fn struct_partial_cmp<S: Struct + ?Sized>(
a: &S,
b: &dyn PartialReflect,
) -> Option<::core::cmp::Ordering> {
#[inline(never)]
pub fn struct_partial_cmp(a: &dyn Struct, b: &dyn PartialReflect) -> Option<::core::cmp::Ordering> {
let ReflectRef::Struct(struct_value) = b.reflect_ref() else {
return None;
};
Expand Down
14 changes: 5 additions & 9 deletions crates/bevy_reflect/src/tuple_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,8 @@ impl<'a> IntoIterator for &'a DynamicTupleStruct {
/// - [`PartialReflect::reflect_partial_eq`] returns `Some(true)` for pairwise fields of `a` and `b`.
///
/// Returns [`None`] if the comparison couldn't even be performed.
#[inline]
pub fn tuple_struct_partial_eq<S: TupleStruct + ?Sized>(
a: &S,
b: &dyn PartialReflect,
) -> Option<bool> {
#[inline(never)]
pub fn tuple_struct_partial_eq(a: &dyn TupleStruct, b: &dyn PartialReflect) -> Option<bool> {
let ReflectRef::TupleStruct(tuple_struct) = b.reflect_ref() else {
return Some(false);
};
Expand All @@ -454,14 +451,13 @@ pub fn tuple_struct_partial_eq<S: TupleStruct + ?Sized>(

Some(true)
}

/// Lexicographically compares two [`TupleStruct`] values and returns their ordering.
///
/// Returns [`None`] if the comparison couldn't be performed (e.g., kinds mismatch
/// or an element comparison returns `None`).
#[inline]
pub fn tuple_struct_partial_cmp<S: TupleStruct + ?Sized>(
a: &S,
#[inline(never)]
pub fn tuple_struct_partial_cmp(
a: &dyn TupleStruct,
b: &dyn PartialReflect,
) -> Option<::core::cmp::Ordering> {
let ReflectRef::TupleStruct(tuple_struct) = b.reflect_ref() else {
Expand Down