优化性能
This commit is contained in:
parent
53616d4c1d
commit
9438539aac
@ -106,6 +106,10 @@ export class IPUtils {
|
|||||||
const hasTarget = targets.some(t => node.contains(t) || t.contains(node));
|
const hasTarget = targets.some(t => node.contains(t) || t.contains(node));
|
||||||
if (!hasTarget) return [];
|
if (!hasTarget) return [];
|
||||||
|
|
||||||
|
if(targets.some(t => this.equal(t, node))) {
|
||||||
|
return [node];
|
||||||
|
}
|
||||||
|
|
||||||
// 如果当前节点包含任何排除项,必须向下拆分
|
// 如果当前节点包含任何排除项,必须向下拆分
|
||||||
const hasExcluded = excluded.some(e => node.contains(e));
|
const hasExcluded = excluded.some(e => node.contains(e));
|
||||||
if (hasExcluded) {
|
if (hasExcluded) {
|
||||||
@ -125,9 +129,7 @@ export class IPUtils {
|
|||||||
if (subResults.length > 1) {
|
if (subResults.length > 1) {
|
||||||
return [node];
|
return [node];
|
||||||
} else {
|
} else {
|
||||||
// 特殊情况:如果当前 node 本身就在 targets 中,且 subResults 为空(因为 targets 可能在更深层)
|
return subResults;
|
||||||
// 或者 subResults 长度就是 1,我们返回 subResults 以保持 mask 尽可能大
|
|
||||||
return subResults.length === 0 ? (targets.some(t => t.contains(node)) ? [node] : []) : subResults;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user