Unity-Technologies / Unity-Technologies/Unity.Mathematics
Use in keyword wherever possible
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.4k
- Forks
- 159
- PR merge metrics
- No merged PRs in 30d
Description
there is no need to indirectly create a copy of parameters in most cases. using in can drastically improve performance for several methods and operators.
for example changing float4 multiply to
public static float4 operator * (in float4 lhs, in float4 rhs) { return new float4 (lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); }
results in a massive performance improvement in .Net 5 (hopefully similar in Mono) ~3.1 ns vs ~0.1 ns (intel 7th gen)
burst might do that already internally but it could finally make this library faster than the built in Vector3/4/... outside of Burst
PS: soon™ https://docs.microsoft.com/en-us/dotnet/api/system.math.sincos?view=net-6.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the float4 multiplication operator shown in the issue, then inspect other methods and operators that copy parameters. Determine which cases can use the in keyword without changing behavior, and verify that the affected operations retain their behavior while improving performance outside Burst.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100