First of all, thank you for your answer.
O(n) is unaffordable. There also exists an O(log2(n)) algorithm, and even that isn't the best.
I meant that inserting in RangeMap requires O(n), since you need to scroll the whole iterator.
I'd really like to see a working implementation or some real-life measurements to prove it being better than our current way.
Parsing the ipfilter is done only once, since you don't usually change your ipfilter every days.
However, I can provide a simple script to convert it to
.db. Having that, we can do some benchmark to see if lookup is faster.
Memory usage
should be strongly reduced, so we just need to implement a faster lookup.
The idea is to save, in the sqlite
.db, ranges as integers, not as strings (as "10.0.0.1" ).
In this way - I think - the lookup
should be more efficient.
I'll try to provide some benchmark.