1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-02 02:14:52 +12:00

work toward resolving #853

This commit is contained in:
gorhill 2017-11-28 13:19:57 -05:00
parent c090fa175e
commit e9968713e4
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 15 additions and 23 deletions

View file

@ -475,7 +475,7 @@ var canRemoveCookie = function(cookieKey, srcHostnames) {
srcHostname = cookieHostname;
var pos;
for (;;) {
if ( srcHostnames.hasOwnProperty(srcHostname) ) {
if ( srcHostnames.has(srcHostname) ) {
if ( µm.mustAllow(srcHostname, cookieHostname, 'cookie') ) {
return false;
}

View file

@ -554,29 +554,21 @@ Matrix.prototype.evaluateSwitchZ = function(switchName, srcHostname) {
/******************************************************************************/
// TODO: In all likelyhood, will have to optmize here, i.e. keeping an
// up-to-date collection of src hostnames with reference count etc.
Matrix.prototype.extractAllSourceHostnames = (function() {
var cachedResult = new Set();
var readTime = 0;
Matrix.prototype.extractAllSourceHostnames = function() {
var srcHostnames = {};
for ( var rule of this.rules.keys() ) {
srcHostnames[rule.slice(0, rule.indexOf(' '))] = true;
}
return srcHostnames;
};
/******************************************************************************/
// TODO: In all likelyhood, will have to optmize here, i.e. keeping an
// up-to-date collection of src hostnames with reference count etc.
Matrix.prototype.extractAllDestinationHostnames = function() {
var desHostnames = {};
for ( var rule of this.rules.keys() ) {
desHostnames[this.desHostnameFromRule(rule)] = true;
}
return desHostnames;
};
return function() {
if ( readTime !== this.modifiedTime ) {
cachedResult.clear();
for ( var rule of this.rules.keys() ) {
cachedResult.add(rule.slice(0, rule.indexOf(' ')));
}
readTime = this.modifiedTime;
}
return cachedResult;
};
})();
/******************************************************************************/