decline-cookies / anvil-unity-dots

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

UnsafeArray - Make AsReadOnly a pure method #293

Closed mbaker3 closed 9 months ago

mbaker3 commented 9 months ago

Make UnsafeArray.AsReadOnly a pure method. This prevents a defensive copy when the instance is readonly

What is the current behaviour?

AsReadonly() is not marked readonly even though it will never mutate the instance. This causes a defensive copy when the instance is readonly referenced (readonly field, in, ref readonly, etc...)

What is the new behaviour?

UnsafeArray.AsReadOnly is marked as readonly indicating to the runtime that it's safe to call this method without creating a defensive copy.

What issues does this resolve?

What PRs does this depend on?

Does this introduce a breaking change?