patricia icon indicating copy to clipboard operation
patricia copied to clipboard

Bool tree could be more efficient

Open tdewolff opened this issue 3 months ago • 1 comments

I guess we could only store true values in the tree, so that if a value exists it returns true, otherwise it returns false. The semantics are slightly different for use-cases which require knowing if a value is present in the tree (even if the value is false), so perhaps this should be a new tree called exists_tree or something. You could remove the internal map entirely which would require less memory and would be faster.

Our use-case is whitelisting IP addresses.

tdewolff avatar Sep 24 '25 18:09 tdewolff

Thinking about this a little more, why do you need a separate map at all? That makes it essentially two separate data structures in one. Why don't you store the values in the nodes themselves?

tdewolff avatar Sep 24 '25 20:09 tdewolff