1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

AdBlockRule: Add copy() method

Faster method to copy rule than parse again the filter.
This commit is contained in:
David Rosca 2014-09-16 10:38:28 +02:00
parent e8cddd16ea
commit 6ae0109115
3 changed files with 28 additions and 1 deletions

View File

@ -111,6 +111,31 @@ AdBlockRule::~AdBlockRule()
delete m_regExp;
}
AdBlockRule* AdBlockRule::copy() const
{
AdBlockRule* rule = new AdBlockRule();
rule->m_subscription = m_subscription;
rule->m_type = m_type;
rule->m_options = m_options;
rule->m_exceptions = m_exceptions;
rule->m_filter = m_filter;
rule->m_matchString = m_matchString;
rule->m_caseSensitivity = m_caseSensitivity;
rule->m_isEnabled = m_isEnabled;
rule->m_isException = m_isException;
rule->m_isInternalDisabled = m_isInternalDisabled;
rule->m_allowedDomains = m_allowedDomains;
rule->m_blockedDomains = m_blockedDomains;
if (m_regExp) {
rule->m_regExp = new RegExp;
rule->m_regExp->regExp = m_regExp->regExp;
rule->m_regExp->matchers = m_regExp->matchers;
}
return rule;
}
AdBlockSubscription* AdBlockRule::subscription() const
{
return m_subscription;

View File

@ -64,6 +64,8 @@ public:
AdBlockRule(const QString &filter = QString(), AdBlockSubscription* subscription = 0);
~AdBlockRule();
AdBlockRule* copy() const;
AdBlockSubscription* subscription() const;
void setSubscription(AdBlockSubscription* subscription);

View File

@ -454,7 +454,7 @@ void AdBlockSubscription::populateCache()
continue;
}
AdBlockRule* copiedRule = new AdBlockRule(originalRule->filter());
AdBlockRule* copiedRule = originalRule->copy();
copiedRule->m_options |= AdBlockRule::DomainRestrictedOption;
copiedRule->m_blockedDomains.append(rule->m_allowedDomains);