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

Skip sorting when there is only one node #28

Merged
merged 1 commit into from
Mar 31, 2020

Conversation

jbuckmccready
Copy link
Collaborator

If numItems <= nodeSize then there is no reason to perform the Hilbert index sort since there is only the root box and one node/tier of boxes below it.

For many use cases this wont provide a meaningful performance gain. However, in the case of repeated and varied input counts for which many may be smaller than nodeSize it is significant (I am seeing around 25-40% increase in speed for some of my use cases in c++), and it comes at almost no cost (a single compare) in the case of larger input counts.

Copy link
Owner

@mourner mourner left a comment

Choose a reason for hiding this comment

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

That's a great catch, thanks a lot! Can you please also add a simple test for the case of of numItems <= nodeSize to make sure this code path is covered?

@jbuckmccready
Copy link
Collaborator Author

I have to get my Javascript dev environment setup but I'll work on this at some point today.

@jbuckmccready
Copy link
Collaborator Author

I added a test case for when numItems < nodeSize, it checks that the indices are not rearranged, the box count is correct, and that the root box extents are correct.

@mourner mourner merged commit 755478c into mourner:master Mar 31, 2020
jbuckmccready referenced this pull request in FObermaier/NetTopologySuite.SandBox Apr 22, 2020
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