optimization
parent
9eb4a24165
commit
f118b840c2
|
@ -181,37 +181,50 @@ void WebPage::topDestinations(QString &document)
|
|||
|
||||
void WebPage::blockedDestinations(QString &document)
|
||||
{
|
||||
QMap<QString,QSet<QString>> uniqueRecords;
|
||||
|
||||
QString blockedDestinationsBlock {m_blockedDestinationsBlock};
|
||||
QString blockedDestinationsList;
|
||||
for (const auto& inst: g::instanses)
|
||||
static QString blockedDestinationsBlock;
|
||||
static bool inited = false;
|
||||
if (not inited)
|
||||
{
|
||||
QMapIterator<QString, QStringList> mIter(inst.second->blackList());
|
||||
inited = true;
|
||||
|
||||
QMap<QString,QSet<QString>> uniqueRecords;
|
||||
|
||||
QString blockedDestinationsList;
|
||||
|
||||
for (const auto& inst: g::instanses)
|
||||
{
|
||||
QMapIterator<QString, QStringList> mIter(inst.second->blackList());
|
||||
while (mIter.hasNext())
|
||||
{
|
||||
auto record = mIter.next();
|
||||
for (const auto& addr: record.value())
|
||||
{
|
||||
uniqueRecords[record.key()].insert(addr);
|
||||
}
|
||||
|
||||
if (not uniqueRecords.contains(record.key()))
|
||||
{
|
||||
uniqueRecords.insert(record.key(), QSet<QString>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMapIterator<QString, QSet<QString>> mIter(uniqueRecords);
|
||||
while (mIter.hasNext())
|
||||
{
|
||||
auto record = mIter.next();
|
||||
for (const auto& addr: record.value())
|
||||
{
|
||||
uniqueRecords[record.key()].insert(addr);
|
||||
}
|
||||
blockedDestinationsList += blockedDestinationItem(record.key(), record.value().values());
|
||||
}
|
||||
|
||||
if (not uniqueRecords.contains(record.key()))
|
||||
{
|
||||
uniqueRecords.insert(record.key(), QSet<QString>());
|
||||
}
|
||||
if (not blockedDestinationsList.isEmpty())
|
||||
{
|
||||
blockedDestinationsBlock = m_blockedDestinationsBlock;
|
||||
blockedDestinationsBlock.replace("{{VALUE}}", blockedDestinationsList);
|
||||
blockedDestinationsBlock = '\n'+blockedDestinationsBlock;
|
||||
}
|
||||
}
|
||||
|
||||
QMapIterator<QString,QSet<QString>> mIter(uniqueRecords);
|
||||
while (mIter.hasNext())
|
||||
{
|
||||
auto record = mIter.next();
|
||||
blockedDestinationsList += blockedDestinationItem(record.key(), record.value().values());
|
||||
}
|
||||
|
||||
blockedDestinationsBlock.replace("{{VALUE}}", blockedDestinationsList);
|
||||
document.replace(g::c::HA_BLOCKED_DESTINTIONS, blockedDestinationsList.isEmpty() ? "" : "\n"+blockedDestinationsBlock);
|
||||
document.replace(g::c::HA_BLOCKED_DESTINTIONS, blockedDestinationsBlock);
|
||||
}
|
||||
|
||||
void WebPage::informationBlock(QString &document)
|
||||
|
|
Loading…
Reference in New Issue