summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-01-21 00:44:26 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-01-21 00:44:26 +0100
commit094258e7cb1cb06db105c5c8d067e58e4a40d22b (patch)
tree38fa0c493faef23e610397fe6dc68f893f5f09cb /src
parentSome leaks fixed in new code (diff)
downloadrekonq-094258e7cb1cb06db105c5c8d067e58e4a40d22b.tar.xz
Save memory!
With this commit, we save (at least) 3 bytes for each AdBlockRule defined (and probably more than 3!). In my installation I have about 100 rules... :)
Diffstat (limited to 'src')
-rw-r--r--src/adblock/adblockmanager.h2
-rw-r--r--src/adblock/adblockrule.cpp19
-rw-r--r--src/adblock/adblockrule.h8
3 files changed, 19 insertions, 10 deletions
diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h
index c07a9492..f01aaca0 100644
--- a/src/adblock/adblockmanager.h
+++ b/src/adblock/adblockmanager.h
@@ -110,11 +110,11 @@
// Qt Includes
#include <QObject>
#include <QNetworkReply>
+#include <QStringList>
// Forward Includes
class QNetworkRequest;
class WebPage;
-class QStringList;
// Definitions
typedef QList<AdBlockRule> AdBlockRuleList;
diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp
index c6fe47c9..9f86ffee 100644
--- a/src/adblock/adblockrule.cpp
+++ b/src/adblock/adblockrule.cpp
@@ -52,17 +52,22 @@
* ============================================================ */
+// Self Includes
#include "adblockrule.h"
+// Qt Includes
+#include <QStringList>
#include <QDebug>
#include <QRegExp>
#include <QUrl>
+// Defines
#define QL1S(x) QLatin1String(x)
#define QL1C(x) QLatin1Char(x)
AdBlockRule::AdBlockRule(const QString &filter)
+ : m_optionMatchRule(false)
{
bool isRegExpRule = false;
@@ -75,11 +80,13 @@ AdBlockRule::AdBlockRule(const QString &filter)
isRegExpRule = true;
}
- int options = parsedLine.indexOf( QL1C('$'), 0);
- if (options >= 0)
+ int optionsNumber = parsedLine.indexOf( QL1C('$'), 0);
+ QStringList options;
+
+ if (optionsNumber >= 0)
{
- m_options = parsedLine.mid(options + 1).split(QL1C(','));
- parsedLine = parsedLine.left(options);
+ options = parsedLine.mid(optionsNumber + 1).split(QL1C(','));
+ parsedLine = parsedLine.left(optionsNumber);
}
if(!isRegExpRule)
@@ -87,10 +94,10 @@ AdBlockRule::AdBlockRule(const QString &filter)
m_regExp = QRegExp(parsedLine, Qt::CaseInsensitive, QRegExp::RegExp2);
- if (m_options.contains( QL1S("match-case") ))
+ if ( options.contains( QL1S("match-case") ))
{
m_regExp.setCaseSensitivity(Qt::CaseSensitive);
- m_options.removeOne( QL1S("match-case") );
+ m_optionMatchRule = true;
}
}
diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h
index 7c4c4161..35715051 100644
--- a/src/adblock/adblockrule.h
+++ b/src/adblock/adblockrule.h
@@ -55,11 +55,11 @@
#define ADBLOCKRULE_H
// Qt Includes
-#include <QStringList>
+#include <QRegExp>
+#include <QString>
// Forward Includes
class QUrl;
-class QRegExp;
class AdBlockRule
@@ -73,7 +73,9 @@ private:
QString convertPatternToRegExp(const QString &wildcardPattern);
QRegExp m_regExp;
- QStringList m_options;
+
+ // Rule Options
+ bool m_optionMatchRule;
};