Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Entity#distanceToSqr #143

Merged
merged 5 commits into from
Oct 29, 2024
Merged

Conversation

HaHaWTH
Copy link
Member

@HaHaWTH HaHaWTH commented Oct 29, 2024

This pull request optimizes Entity#distanceToSqr call by using Math#fma which is around 1.2x to 4x faster than original method on CPUs support Fused Multiply-Add (FMA) operation,
avoids multiple casting in Entity#distanceTo, using Math#hypot instead of Mojang's Mth#sqrt. Additionally, this patch makes
these methods more able to be inlined by the JIT compiler.

FMA can be enabled via system property.

@Dreeam-qwq
Copy link
Member

斜斜

@Dreeam-qwq Dreeam-qwq merged commit c6c6224 into Winds-Studio:ver/1.21.1 Oct 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants