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 layer iteration to prevent performance overhead. #3022

Merged

Conversation

NonSwag
Copy link
Contributor

@NonSwag NonSwag commented Dec 8, 2024

Overview

Clamp the min and max y values to the min and max values of the chunk

Description

Adjusted the layer iteration logic in the Region class to use the minimum and maximum Y-values from the chunk. This prevents unnecessary iterations when getMinimumY or getMaximumY returns extreme values, improving performance efficiency.

Submitter Checklist

Preview Give feedback

Adjusted the layer iteration logic in the Region class to use the minimum and maximum Y-values from the chunk. This prevents unnecessary iterations when getMinimumY or getMaximumY returns extreme values, improving performance efficiency.
@NonSwag NonSwag requested a review from a team as a code owner December 8, 2024 11:53
@NonSwag
Copy link
Contributor Author

NonSwag commented Dec 8, 2024

I was not sure whether it would be more appropriate to use getMinSectionPosition or getMaxSectionPosition over getMinY or getMaxY
Input on that would be appreciated

Refactored the loop to reduce repeated evaluations by storing pre-calculated min and max values for Y coordinates. This change enhances readability and may improve performance by minimizing unnecessary calculations during the iteration process.
@PierreSchwang PierreSchwang added the Bugfix This PR fixes a bug label Dec 11, 2024
@PierreSchwang
Copy link
Member

Would be great if the variables would either be called minY instead of minLayer or keep them minLayer but put the bit shift directly after the Math.min/max instead of inside the loop - just so that the naming fits

@PierreSchwang PierreSchwang merged commit afec252 into IntellectualSites:main Dec 15, 2024
10 checks passed
@NonSwag NonSwag deleted the max-min-layer-performance branch December 15, 2024 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix This PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants