summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qtldurl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qtldurl.cpp')
-rw-r--r--src/corelib/io/qtldurl.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index 436e6a4568..dd4301e9f1 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -51,12 +51,22 @@ QT_BEGIN_NAMESPACE
static bool containsTLDEntry(const QString &entry)
{
int index = qt_hash(entry) % tldCount;
- int currentDomainIndex = tldIndices[index];
- while (currentDomainIndex < tldIndices[index+1]) {
- QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex);
+
+ // select the right chunk from the big table
+ short chunk = 0;
+ uint chunkIndex = tldIndices[index], offset = 0;
+ while (tldIndices[index] >= tldChunks[chunk] && chunk < tldChunkCount) {
+ chunkIndex -= tldChunks[chunk];
+ offset += tldChunks[chunk];
+ chunk++;
+ }
+
+ // check all the entries from the given index
+ while (chunkIndex < tldIndices[index+1] - offset) {
+ QString currentEntry = QString::fromUtf8(tldData[chunk] + chunkIndex);
if (currentEntry == entry)
return true;
- currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; // +1 for the ending \0
+ chunkIndex += qstrlen(tldData[chunk] + chunkIndex) + 1; // +1 for the ending \0
}
return false;
}