decline-cookies / anvil-unity-dots

Unity DOTS and ECS specific additions and extensions to Anvil
MIT License
4 stars 1 forks source link

No box equals #255

Closed mbaker3 closed 1 year ago

mbaker3 commented 1 year ago

Implement a generic equality check for unmanaged types that doesn't cause them to be boxed. Leveraging this allows the assertion in AccessController to execute without any managed allocations.

What is the current behaviour?

Trying to perform an equality check between JobHandle instances results in boxing. This applies to any value types that don't implement IEquatable<T> or the == operator.

AccessController's assertion produces garbage on every execution.

What is the new behaviour?

UnsafeUtil.Equals_NoBox<T>() provides a way to check the equality between two unamanged instances by directly comparing their memory.

JobHandle.Equals_NoBox provides a way to perform an equality check between two JobHandle instances without boxing.

AccessController's assertion no longer produces garbage.

What issues does this resolve?

What PRs does this depend on?

Does this introduce a breaking change?