1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-02 17:02:40 +01:00

code review: reset internal parser data once done parsing

This commit is contained in:
Raymond Hill 2018-03-06 15:46:05 -05:00
parent ec56165d0d
commit 15530df0e7
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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()
};
};