1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

improve in-memory storage of specific cosmetic filters + more ES6

- collate together specific filters with same base domain
- replace string-based hash to integer-based hash
- revisit code to benefit from ES6-specific syntax
This commit is contained in:
Raymond Hill 2018-05-31 10:41:03 -04:00
parent 23979c3197
commit ab867dedf5
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 425 additions and 409 deletions

View File

@ -135,10 +135,10 @@ var µBlock = (function() { // jshint ignore:line
localSettingsLastModified: 0,
localSettingsLastSaved: 0,
// read-only
// Read-only
systemSettings: {
compiledMagic: 1,
selfieMagic: 1
compiledMagic: 2, // Increase when compiled format changes
selfieMagic: 2 // Increase when selfie format changes
},
restoreBackupSettings: {

File diff suppressed because it is too large Load Diff

View File

@ -519,7 +519,7 @@ var onMessage = function(request, sender, callback) {
request.domain = µb.URI.domainFromHostname(request.hostname);
request.entity = µb.URI.entityFromDomain(request.domain);
response.specificCosmeticFilters =
µb.cosmeticFilteringEngine.retrieveDomainSelectors(request, response);
µb.cosmeticFilteringEngine.retrieveSpecificSelectors(request, response);
if ( µb.canInjectScriptletsNow === false ) {
response.scriptlets = µb.scriptletFilteringEngine.retrieve(request);
}

View File

@ -203,14 +203,8 @@ var fromCosmeticFilter = function(details) {
}
break;
case 8:
case 9:
case 32:
case 64:
case 65:
if ( exception !== (fargs[1].charAt(0) === '!') ) {
break;
}
isProcedural = fargs[3].charCodeAt(0) === 0x7B;
if ( exception !== ((fargs[1] & 0b01) !== 0) ) { break; }
isProcedural = (fargs[1] & 0b10) !== 0;
if (
isProcedural === false && fargs[3] !== selector ||
isProcedural && JSON.parse(fargs[3]).raw !== selector
@ -225,6 +219,19 @@ var fromCosmeticFilter = function(details) {
found = fargs[2] + prefix + selector;
}
break;
case 32:
case 64:
case 65:
if ( exception !== (fargs[1].charAt(0) === '!') ) { break; }
if ( fargs[3] !== selector ) { break; }
if (
fargs[2] === '' ||
reHostname.test(fargs[2]) === true ||
reEntity !== undefined && reEntity.test(fargs[2]) === true
) {
found = fargs[2] + prefix + selector;
}
break;
}
if ( found !== undefined ) {
if ( response[found] === undefined ) {