From 9a25b11cc97f453b4c82d68c76a8c4026fd62b21 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 2 Dec 2009 11:42:10 +0100 Subject: trade-off: speed vs mem saving. This time I decided for speed.. --- src/adblock/adblockmanager.cpp | 24 ++++-------------------- src/adblock/adblockmanager.h | 6 ++++-- src/adblock/adblockrule.h | 1 + 3 files changed, 9 insertions(+), 22 deletions(-) (limited to 'src/adblock') diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index 4f4cff51..bfdbd5ad 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -30,7 +30,6 @@ // Local Includes #include "adblocknetworkreply.h" -#include "adblockrule.h" // KDE Includes #include @@ -76,7 +75,8 @@ void AdBlockManager::loadSettings() if (name.startsWith(QLatin1String("Filter"))) { - filterList << url; + AdBlockRule filter(url); + filterList << filter; } } } @@ -95,30 +95,14 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request) QString urlString = request.url().toString(); kDebug() << "****************************** ADBLOCK: Matching url: "<< urlString; - foreach(const QString &filter, filterList) + foreach(const AdBlockRule &filter, filterList) { - AdBlockRule rule(filter); - if(rule.match(urlString)) + if(filter.match(urlString)) { kDebug() << "****ADBLOCK: Matched: **************************"; AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this); return reply; } } - - - - // Check the blacklist, and only if that matches, the whitelist - - - - - -// if(_adBlackList.isUrlMatched(urlString) && !_adWhiteList.isUrlMatched(urlString)) -// { -// kDebug() << "****ADBLOCK: Matched: **************************"; -// AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this); -// return reply; -// } return 0; } diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h index 32f123fd..499a0cde 100644 --- a/src/adblock/adblockmanager.h +++ b/src/adblock/adblockmanager.h @@ -28,10 +28,12 @@ #ifndef ADBLOCK_MANAGER_H #define ADBLOCK_MANAGER_H +// Local Includes +#include "adblockrule.h" +typedef QList AdBlockRuleList; // Qt Includes #include -#include #include // Forward Includes @@ -53,7 +55,7 @@ private: bool _isAdblockEnabled; bool _isHideAdsEnabled; - QStringList filterList; + AdBlockRuleList filterList; }; #endif diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h index 3f1bd8bf..8680942f 100644 --- a/src/adblock/adblockrule.h +++ b/src/adblock/adblockrule.h @@ -79,4 +79,5 @@ private: QStringList m_options; }; + #endif // ADBLOCKRULE_H -- cgit v1.2.1