mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-14 18:20:35 +08:00
Perf: perform hint on reject domain dedupe
This commit is contained in:
parent
6fe7655435
commit
09887a629f
@ -4,7 +4,10 @@ const { workerData, move } = require('piscina');
|
|||||||
// This avoid calling chatCodeAt repeatedly
|
// This avoid calling chatCodeAt repeatedly
|
||||||
|
|
||||||
// workerData is an array of string. Sort it by length, short first:
|
// workerData is an array of string. Sort it by length, short first:
|
||||||
const fullsetDomainStartsWithADot = workerData.sort((a, b) => a.length - b.length).filter(domain => domain.charCodeAt(0) === 46);
|
const fullsetDomainStartsWithADot = workerData.filter(domain => (
|
||||||
|
domain.charCodeAt(0) === 46
|
||||||
|
&& !canExcludeFromDedupe(domain)
|
||||||
|
));
|
||||||
const totalLen = fullsetDomainStartsWithADot.length;
|
const totalLen = fullsetDomainStartsWithADot.length;
|
||||||
|
|
||||||
module.exports = ({ chunk }) => {
|
module.exports = ({ chunk }) => {
|
||||||
@ -14,6 +17,10 @@ module.exports = ({ chunk }) => {
|
|||||||
for (let i = 0; i < chunkLength; i++) {
|
for (let i = 0; i < chunkLength; i++) {
|
||||||
const domainFromInput = chunk[i];
|
const domainFromInput = chunk[i];
|
||||||
|
|
||||||
|
if (canExcludeFromDedupe(domainFromInput)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (let j = 0; j < totalLen; j++) {
|
for (let j = 0; j < totalLen; j++) {
|
||||||
const domainFromFullSet = fullsetDomainStartsWithADot[j];
|
const domainFromFullSet = fullsetDomainStartsWithADot[j];
|
||||||
// domainFromFullSet is now startsWith a "."
|
// domainFromFullSet is now startsWith a "."
|
||||||
@ -56,3 +63,11 @@ module.exports = ({ chunk }) => {
|
|||||||
|
|
||||||
return move(outputToBeRemoved);
|
return move(outputToBeRemoved);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// duckdns.org domain will not overlap and doesn't need dedupe
|
||||||
|
function canExcludeFromDedupe(domain) {
|
||||||
|
if (domain.endsWith('.duckdns.org')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user