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

code review

This commit is contained in:
gorhill 2015-03-04 19:43:15 -05:00
parent a99bcd98fd
commit 455dfeca8c

View File

@ -150,11 +150,22 @@ Matrix.prototype.assign = function(other) {
Matrix.prototype.copyRules = function(other, srcHostname, desHostnames) { Matrix.prototype.copyRules = function(other, srcHostname, desHostnames) {
var thisRules = this.rules; var thisRules = this.rules;
var otherRules = other.rules; var otherRules = other.rules;
var ruleKey, ruleValue;
// Specific types // Specific types
thisRules['* *'] = otherRules['* *']; ruleValue = otherRules['* *'] || 0;
var ruleKey = srcHostname + ' *'; if ( ruleValue !== 0 ) {
thisRules[ruleKey] = otherRules[ruleKey]; thisRules['* *'] = ruleValue;
} else {
delete thisRules['* *'];
}
ruleKey = srcHostname + ' *';
ruleValue = otherRules[ruleKey] || 0;
if ( ruleValue !== 0 ) {
thisRules[ruleKey] = ruleValue;
} else {
delete thisRules[ruleKey];
}
// Specific destinations // Specific destinations
for ( var desHostname in desHostnames ) { for ( var desHostname in desHostnames ) {
@ -162,9 +173,19 @@ Matrix.prototype.copyRules = function(other, srcHostname, desHostnames) {
continue; continue;
} }
ruleKey = '* ' + desHostname; ruleKey = '* ' + desHostname;
thisRules[ruleKey] = otherRules[ruleKey]; ruleValue = otherRules[ruleKey] || 0;
if ( ruleValue !== 0 ) {
thisRules[ruleKey] = ruleValue;
} else {
delete thisRules[ruleKey];
}
ruleKey = srcHostname + ' ' + desHostname ; ruleKey = srcHostname + ' ' + desHostname ;
thisRules[ruleKey] = otherRules[ruleKey]; ruleValue = otherRules[ruleKey] || 0;
if ( ruleValue !== 0 ) {
thisRules[ruleKey] = ruleValue;
} else {
delete thisRules[ruleKey];
}
} }
return true; return true;