Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/filter/RegExpFilter.h

Issue 29581602: Issue 5141 - [emscripten] Convert filter matcher to C++ Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created Oct. 17, 2017, 12:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiled/filter/RegExpFilter.h
===================================================================
--- a/compiled/filter/RegExpFilter.h
+++ b/compiled/filter/RegExpFilter.h
@@ -21,39 +21,30 @@
#include "ActiveFilter.h"
#include "../bindings/runtime.h"
enum class TrippleState {YES, NO, ANY};
struct RegExpFilterData
{
mutable String::size_type mPatternStart;
- union
- {
- mutable int mRegexpId;
- mutable String::size_type mPatternEnd;
- };
Wladimir Palant 2017/10/17 12:51:21 The matcher might need to access the pattern part
+ mutable String::size_type mPatternEnd;
+ mutable int mRegexpId;
mutable String::size_type mDomainsStart;
mutable String::size_type mDomainsEnd;
mutable String::size_type mSitekeysStart;
mutable String::size_type mSitekeysEnd;
int mContentType;
bool mMatchCase;
TrippleState mThirdParty;
TrippleState mCollapse;
bool RegExpParsingDone() const
{
- return mPatternStart == String::npos;
- }
-
- void SetRegExp(int regexpId) const
- {
- mRegexpId = regexpId;
- mPatternStart = String::npos;
+ return mRegexpId >= 0;
}
bool HasRegExp() const
{
return RegExpParsingDone() && mRegexpId;
}
const DependentString GetRegExpSource(const String& text) const
@@ -106,11 +97,15 @@ public:
static constexpr Type classType = Type::REGEXP;
explicit RegExpFilter(Type type, const String& text, const RegExpFilterData& data);
~RegExpFilter();
static Type Parse(DependentString& text, DependentString& error,
RegExpFilterData& data);
static void GenerateCustomBindings();
bool BINDINGS_EXPORTED Matches(const String& location, int typeMask,
DependentString& docDomain, bool thirdParty, const String& sitekey) const;
+ const DependentString GetRegExpSource() const
+ {
+ return mData.GetRegExpSource(mText);
+ }
};
typedef intrusive_ptr<RegExpFilter> RegExpFilterPtr;

Powered by Google App Engine
This is Rietveld