patricia
patricia copied to clipboard
Bool tree could be more efficient
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.
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?