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

3x speedup of the distance transform. #28

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

khoover
Copy link
Contributor

@khoover khoover commented Sep 9, 2024

By avoiding checked adds and instead manually iterating over the correct windows of RoomXYs, we obtain a 3x speedup over the naive filter_map-based implementation.

By avoiding checked adds and instead manually iterating over the
correct windows of `RoomXY`s, we obtain a 3x speedup over the naive
`filter_map`-based implementation.
Comment on lines -35 to -36
// Copy the initial cost matrix into the output cost matrix
let mut cm = initial_cm.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually never needed this clone, since we get the cost-matrix by value; the old owner can't do anything with it.

Get rid of the windowing vector, map to the array of surrounding y-
coordinates.
@khoover khoover requested a review from shanemadden September 10, 2024 02:02
@shanemadden shanemadden merged commit c58d75e into rustyscreeps:main Sep 10, 2024
2 checks passed
@khoover khoover deleted the distance_transform_speedup branch September 10, 2024 06:09
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