-
Notifications
You must be signed in to change notification settings - Fork 117
Use primitive array in Point instead of List #1630
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
base: main
Are you sure you want to change the base?
Conversation
| if (altitudes == null) { | ||
| altitudes = new double[points.size()]; | ||
| // Fill in any previous altitude as NaN | ||
| for (int j = 0; j < i; j++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just pre-fill all array with NaN and then set valid values on top of it during i cycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would result in unnecessary CPU cycles for the non-NaN future ones.
I don't have hard numbers but I would imagine that if the points have altitude I guess most of them will have it. I think (again no evidence) the pattern will be that either there's altitude for all points or there's none.
Or is there a fast way to pre-fill with NaN? without iterating one by one?
Avoid using
List<Double>forPoint. Instead usedouble [].Moreover, expose accessors to the flatten structure.
This change improves memory usage significantly: