Skip to content

Commit

Permalink
testing: fix performance when unloading a bunch of tests (#197294)
Browse files Browse the repository at this point in the history
We were unnecessary recomputing the state for child items, when we only needed to do so for the removed root

Fixes #193240
  • Loading branch information
connor4312 authored Nov 3, 2023
1 parent 0e9376c commit 3982a39
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ export class TreeProjection extends Disposable implements ITestTreeProjection {
}

// The first element will cause the root to be hidden
const affectsRootElement = toRemove.depth === 1 && toRemove.parent?.children.size === 1;
this.changedParents.add(affectsRootElement ? null : toRemove.parent);
const parent = toRemove.parent;
const affectsRootElement = toRemove.depth === 1 && parent?.children.size === 1;
this.changedParents.add(affectsRootElement ? null : parent);

const queue: Iterable<TestExplorerTreeElement>[] = [[toRemove]];
while (queue.length) {
Expand All @@ -235,6 +236,10 @@ export class TreeProjection extends Disposable implements ITestTreeProjection {
}
}
}

if (parent instanceof TreeTestItemElement) {
refreshComputedState(computedStateAccessor, parent, undefined, !!parent.duration).forEach(i => i.fireChange());
}
}
}
}
Expand Down Expand Up @@ -290,10 +295,6 @@ export class TreeProjection extends Disposable implements ITestTreeProjection {
const parent = treeElement.parent;
parent?.children.delete(treeElement);
this.items.delete(treeElement.test.item.extId);
if (parent instanceof TreeTestItemElement) {
refreshComputedState(computedStateAccessor, parent, undefined, !!treeElement.duration).forEach(i => i.fireChange());
}

return treeElement.children;
}

Expand Down

0 comments on commit 3982a39

Please sign in to comment.