From 15530df0e79a05cad75994138aaeaa684953aa52 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 6 Mar 2018 15:46:05 -0500 Subject: [PATCH] code review: reset internal parser data once done parsing --- src/js/static-ext-filtering.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/js/static-ext-filtering.js b/src/js/static-ext-filtering.js index 6c334dd6d..c4da31bd7 100644 --- a/src/js/static-ext-filtering.js +++ b/src/js/static-ext-filtering.js @@ -62,6 +62,13 @@ suffix: '' }; + // To be called to ensure no big parent string of a string slice is + // left into memory after parsing filter lists is over. + var resetParsed = function() { + parsed.hostnames = []; + parsed.suffix = ''; + }; + var isValidCSSSelector = (function() { var div = document.createElement('div'), matchesFn; @@ -458,6 +465,7 @@ µb.cosmeticFilteringEngine.reset(); µb.scriptletFilteringEngine.reset(); µb.htmlFilteringEngine.reset(); + resetParsed(parsed); }; api.freeze = function() { @@ -465,6 +473,7 @@ µb.cosmeticFilteringEngine.freeze(); µb.scriptletFilteringEngine.freeze(); µb.htmlFilteringEngine.freeze(); + resetParsed(parsed); }; // https://github.com/chrisaljoudi/uBlock/issues/1004 @@ -691,7 +700,6 @@ cosmetic: µb.cosmeticFilteringEngine.toSelfie(), scriptlets: µb.scriptletFilteringEngine.toSelfie(), html: µb.htmlFilteringEngine.toSelfie() - }; };