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

trie/trie.go improve the delete performance #22960

Closed
wants to merge 1 commit into from
Closed

trie/trie.go improve the delete performance #22960

wants to merge 1 commit into from

Conversation

Evolution404
Copy link
Contributor

@Evolution404 Evolution404 commented May 28, 2021

when nn is not nil, there is no need to check the number of non-nil entries

Comment on lines +418 to +420
if nn != nil {
pos = -2
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this hard to intuitively verify. I think it might be easier to follow if you break here, so replace this with

if nn != nil{	
	// n still contains at least two values and cannot be reduced.
	return true, n, nil
}

As far as I can tell, that^ change should be equivalent with your change. However, looking at it, I still don't see why this is necessarily true/correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if nn != nil, nn must be a child of n, which means that n itself doesn't need to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And before the deletion, there must be another child of n.

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