Most of filter rules are domain specific. If we put filters start with "|", "||", "@@||" into their own list of rules with a given domain, then the giant regex will be cut into 1/3 of the original size. The domain specified rules will be quite short.
Each domain can then be put into a dict mapping to the respected filter rules.
And most rest of the rules have the string "ad" in it. if we seperate rest of the rules by whether a rule has "ad" in it, we can have a much smaller regex for urls without "ad".
domain_rules = {
"host1": merged_regex,
"host2": merged_regex
...
}
rules_with_ad = merged_regex
rules_without_ad = merged_regex
Since most false postive urls don't match domains and has no ad in them, matching false positive should be much faster.
Most of filter rules are domain specific. If we put filters start with "|", "||", "@@||" into their own list of rules with a given domain, then the giant regex will be cut into 1/3 of the original size. The domain specified rules will be quite short.
Each domain can then be put into a dict mapping to the respected filter rules.
And most rest of the rules have the string "ad" in it. if we seperate rest of the rules by whether a rule has "ad" in it, we can have a much smaller regex for urls without "ad".
Since most false postive urls don't match domains and has no
adin them, matching false positive should be much faster.