mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Perf: improve reject set dedupe performance
This commit is contained in:
parent
f0c517f0bf
commit
939a119a52
@ -6,15 +6,33 @@ exports.dedupe = ({ chunk }) => {
|
|||||||
for (let i = 0, l = chunk.length; i < l; i++) {
|
for (let i = 0, l = chunk.length; i < l; i++) {
|
||||||
const domainFromInput = chunk[i];
|
const domainFromInput = chunk[i];
|
||||||
for (const domainFromFullSet of workerData) {
|
for (const domainFromFullSet of workerData) {
|
||||||
|
if (outputToBeRemoved.has(domainFromFullSet)) continue;
|
||||||
if (domainFromFullSet === domainFromInput) continue;
|
if (domainFromFullSet === domainFromInput) continue;
|
||||||
if (domainFromFullSet.charAt(0) !== '.') continue;
|
if (domainFromFullSet.charAt(0) !== '.') continue;
|
||||||
|
// domainFromFullSet is now startsWith a "."
|
||||||
|
|
||||||
if (
|
if (domainFromInput.charAt(0) !== '.') {
|
||||||
(domainFromInput.charAt(0) !== '.' && `.${domainFromInput}` === domainFromFullSet)
|
let shouldBeRemoved = true;
|
||||||
|| domainFromInput.endsWith(domainFromFullSet)
|
|
||||||
) {
|
for (let j = 0, l2 = domainFromInput.length; j < l2; j++) {
|
||||||
outputToBeRemoved.add(domainFromInput);
|
if (domainFromFullSet.charAt(j + 1) !== domainFromInput.charAt(j)) {
|
||||||
break;
|
shouldBeRemoved = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldBeRemoved) {
|
||||||
|
outputToBeRemoved.add(domainFromInput);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// domainFromInput is now startsWith a "."
|
||||||
|
|
||||||
|
if (domainFromInput.length >= domainFromFullSet.length) {
|
||||||
|
if (domainFromInput.endsWith(domainFromFullSet)) {
|
||||||
|
outputToBeRemoved.add(domainFromInput);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user