[Content Extensions] Only add unique universal action locations.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Apr 2015 19:46:29 +0000 (19:46 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Apr 2015 19:46:29 +0000 (19:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143325

Reviewed by Benjamin Poulain.

* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
Use a HashSet instead of a Vector for the universal action locations to remove duplicates.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182283 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp

index e948b3a..7da0840 100644 (file)
@@ -1,3 +1,14 @@
+2015-04-02  Alex Christensen  <achristensen@webkit.org>
+
+        [Content Extensions] Only add unique universal action locations.
+        https://bugs.webkit.org/show_bug.cgi?id=143325
+
+        Reviewed by Benjamin Poulain.
+
+        * contentextensions/ContentExtensionCompiler.cpp:
+        (WebCore::ContentExtensions::compileRuleList):
+        Use a HashSet instead of a Vector for the universal action locations to remove duplicates.
+
 2015-04-01  Roger Fong  <roger_fong@apple.com>
 
         Fix slider colors for media controls on OSX.
index 142bc64..6c0ad8e 100644 (file)
@@ -133,7 +133,7 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, const
 
     Vector<SerializedActionByte> actions;
     Vector<unsigned> actionLocations = serializeActions(parsedRuleList, actions);
-    Vector<uint64_t> universalActionLocations;
+    HashSet<uint64_t, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> universalActionLocations;
 
     CombinedURLFilters combinedURLFilters;
     URLFilterParser urlFilterParser(combinedURLFilters);
@@ -148,10 +148,9 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, const
         URLFilterParser::ParseStatus status = urlFilterParser.addPattern(trigger.urlFilter, trigger.urlFilterIsCaseSensitive, actionLocationAndFlags);
 
         if (status == URLFilterParser::MatchesEverything) {
-
             if (ignorePreviousRulesSeen)
                 return ContentExtensionError::RegexMatchesEverythingAfterIgnorePreviousRules;
-            universalActionLocations.append(actionLocationAndFlags);
+            universalActionLocations.add(actionLocationAndFlags);
         }
 
         if (status != URLFilterParser::Ok && status != URLFilterParser::MatchesEverything) {