mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-13 10:17:34 +01:00
code review: reset internal parser data once done parsing
This commit is contained in:
parent
ec56165d0d
commit
15530df0e7
1 changed files with 9 additions and 1 deletions
|
@ -62,6 +62,13 @@
|
||||||
suffix: ''
|
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 isValidCSSSelector = (function() {
|
||||||
var div = document.createElement('div'),
|
var div = document.createElement('div'),
|
||||||
matchesFn;
|
matchesFn;
|
||||||
|
@ -458,6 +465,7 @@
|
||||||
µb.cosmeticFilteringEngine.reset();
|
µb.cosmeticFilteringEngine.reset();
|
||||||
µb.scriptletFilteringEngine.reset();
|
µb.scriptletFilteringEngine.reset();
|
||||||
µb.htmlFilteringEngine.reset();
|
µb.htmlFilteringEngine.reset();
|
||||||
|
resetParsed(parsed);
|
||||||
};
|
};
|
||||||
|
|
||||||
api.freeze = function() {
|
api.freeze = function() {
|
||||||
|
@ -465,6 +473,7 @@
|
||||||
µb.cosmeticFilteringEngine.freeze();
|
µb.cosmeticFilteringEngine.freeze();
|
||||||
µb.scriptletFilteringEngine.freeze();
|
µb.scriptletFilteringEngine.freeze();
|
||||||
µb.htmlFilteringEngine.freeze();
|
µb.htmlFilteringEngine.freeze();
|
||||||
|
resetParsed(parsed);
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/1004
|
// https://github.com/chrisaljoudi/uBlock/issues/1004
|
||||||
|
@ -691,7 +700,6 @@
|
||||||
cosmetic: µb.cosmeticFilteringEngine.toSelfie(),
|
cosmetic: µb.cosmeticFilteringEngine.toSelfie(),
|
||||||
scriptlets: µb.scriptletFilteringEngine.toSelfie(),
|
scriptlets: µb.scriptletFilteringEngine.toSelfie(),
|
||||||
html: µb.htmlFilteringEngine.toSelfie()
|
html: µb.htmlFilteringEngine.toSelfie()
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue