-
Notifications
You must be signed in to change notification settings - Fork 82
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
Consider removing overhead of NodeUtil#ensureNoDuplicateEdges() #22
Comments
Yes, this is a good point. This is an example of defensive programming to ensure the algorithms didn't violate the constraints! But indeed I think the algorithms are well proven now, and they don't violate the constraints. So it makes sense to allow this checking to be relaxed. It would be quite easy to add a constructor to the node factories which would allow this checking to be disabled. So I'll accept this suggestion, and try to add it for the next release! Thanks! |
Excellent! |
@VHarisop Yes that looks good. Also one minor point - could you add brackets {} in the if statement - just for consistency with code style? If you create a PR from with these changes, I'd be happy to merge it. Thanks! |
Cool, I'll look into writing the tests. |
For my particular tree I have run some performance measurements indicating that around 15% of the time constructing a tree is spent in NodeUtil#ensureNoDuplicateEdges(). I think that is a rather steep price to be paying.
AFAICT it shouldn't be possible to violate this constraint in the first place (the ConcurrentRadixTree implementation looks correct). So if this is to help people implementing their own implementation, maybe there could be some debug flag to guard this? Alternatives would be: Speed it up (e.g. for edge cases like size() <= 2) or move it into the node constructor, where once the children are sorted it would only be a matter of looping over all children and finding any two adjacent identical ones. Should be cheaper.
Thoughts?
The text was updated successfully, but these errors were encountered: