From f35dff2c9d9e2ee55c53b32767698ba46ca3c39b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 29 Dec 2018 16:34:46 -0500 Subject: [PATCH 1/3] Code review related to performance in main content script - Avoid concatenating with empty array: though the concatenated array is empty, this still forces the creation of a whole new array as per semantic of Array.prototype.concat(). - Do not convert arrays to strings when sending data to main process in surveyPhase1(): I no longer see any benefit doing so in profiling data (if I recall properly this was benefiting Firefox, but I can't remember for sure anymore why I chose to do so back then). --- src/js/contentscript.js | 8 +++++--- src/js/cosmetic-filtering.js | 12 +++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 4facff119..f7fd6fad3 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -1147,7 +1147,9 @@ vAPI.domSurveyor = (function() { pending.nodes = added; } else { nodes = pending.nodes.splice(0, 1000); - pending.nodes = pending.nodes.concat(added); + if ( added.length !== 0 ) { + pending.nodes = pending.nodes.concat(added); + } } return nodes; }; @@ -1212,8 +1214,8 @@ vAPI.domSurveyor = (function() { { what: 'retrieveGenericCosmeticSelectors', hostname: hostname, - ids: ids.join('\n'), - classes: classes.join('\n'), + ids: ids, + classes: classes, exceptions: domFilterer.exceptions, cost: surveyCost }, diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 6d30a36d8..d10eb4100 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -1054,14 +1054,8 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) { for ( let type in this.lowlyGeneric ) { let entry = this.lowlyGeneric[type]; let selectors = request[entry.canonical]; - if ( typeof selectors !== 'string' ) { continue; } - let strEnd = selectors.length; - let sliceBeg = 0; - do { - let sliceEnd = selectors.indexOf('\n', sliceBeg); - if ( sliceEnd === -1 ) { sliceEnd = strEnd; } - let selector = selectors.slice(sliceBeg, sliceEnd); - sliceBeg = sliceEnd + 1; + if ( Array.isArray(selectors) === false ) { continue; } + for ( let selector of selectors ) { if ( entry.simple.has(selector) === false ) { continue; } let bucket = entry.complex.get(selector); if ( bucket !== undefined ) { @@ -1080,7 +1074,7 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) { simpleSelectors.add(selector); } } - } while ( sliceBeg < strEnd ); + } } // Apply exceptions: it is the responsibility of the caller to provide From 3e0b82749caef0059caf7c096dd7cae58090bf75 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 29 Dec 2018 16:44:04 -0500 Subject: [PATCH 2/3] New revision for dev build --- dist/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/version b/dist/version index 96ec1ff63..0241b427a 100644 --- a/dist/version +++ b/dist/version @@ -1 +1 @@ -1.17.5.103 +1.17.5.104 From dcf6046f8c4ef15bce9235ac3e8688c5f1d2437b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 29 Dec 2018 16:52:41 -0500 Subject: [PATCH 3/3] make Firefox dev build auto-update --- dist/firefox/updates.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/firefox/updates.json b/dist/firefox/updates.json index 528786640..ad0adcf00 100644 --- a/dist/firefox/updates.json +++ b/dist/firefox/updates.json @@ -3,10 +3,10 @@ "uBlock0@raymondhill.net": { "updates": [ { - "version": "1.17.5.103", + "version": "1.17.5.104", "applications": { "gecko": { "strict_min_version": "52" } }, - "update_info_url": "https://github.com/gorhill/uBlock/releases/tag/1.17.5rc3", - "update_link": "https://github.com/gorhill/uBlock/releases/download/1.17.5rc3/uBlock0_1.17.5rc3.firefox.signed.xpi" + "update_info_url": "https://github.com/gorhill/uBlock/releases/tag/1.17.5rc4", + "update_link": "https://github.com/gorhill/uBlock/releases/download/1.17.5rc4/uBlock0_1.17.5rc4.firefox.signed.xpi" } ] }