![]() Registered Member ![]()
|
Hi,
First, apologies if this is answered in a FAQ somewhere (tried finding it, etc.). I'm wondering what the technical reasons are for the (lack of) speed in this conversion -- I found it alluded to somewhere that the reason for doing it at all is to save memory at runtime, and I applaud that decision... However, being a compsci student with a minor in mathematics, I can't help but wonder if it can be optimized a little :) I glanced at the source code a bit, but I've never worked with C++ * (though I do know enough C to get by) -- the bits in ./plugins/ipfilter aren't commented very much. Anyway, if someone could describe to me a bit of what's going on when the list gets converted, I'd love to have a go at making it go faster. ~Felix. *: University of Victoria is teaching us bloody Java instead, which annoys me a bit. |
![]() Registered Member ![]()
|
Converting is done in ipfilter ConvertDialog::convert().
We convert plain text IP ranges to a binary file format (ipblock struct) and KT loads so called 'antip2p header' from this file containing about 100 of these blocks, then we binary search header when checking for an ip after which we binary search the file itself. It's much better than keeping 5MB+ file in RAM and searching and it's pretty fast too. I've noticed it gets slow and my guess is that Qt is making some weirdness there. You probably noticed how things go pretty fast at the beginning and at the end it gets really slow. It can probably be optimized so if you care to help, please do so. |
![]() Registered Member ![]()
|
I have emailed a patch correcting this issue to Joris after confirming that it was not fixed in SVN. The problem was that the slow part iterated over a QStringList using QStringList::operator[]() (i.e., subscripting), which takes linear time in Qt 3. I fixed it by using QStringList::iterator instead.
|
![]() Moderator ![]()
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]