Use indices for queue processing instead of Array.shift() (#236601)

* Use indices instead of Array.shift()

* 💄
pull/236607/head
Benjamin Christopher Simmonds 2024-12-19 16:51:06 +01:00 committed by GitHub
parent f990dfb385
commit ffbf5a7f28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -3080,16 +3080,16 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
}
const root = this.model.getNode();
const queue = [root];
const stack = [root];
while (queue.length > 0) {
const node = queue.shift()!;
while (stack.length > 0) {
const node = stack.pop()!;
if (node !== root && node.collapsible) {
state.expanded[getId(node.element)] = node.collapsed ? 0 : 1;
}
insertInto(queue, queue.length, node.children);
insertInto(stack, stack.length, node.children);
}
return state;

View File

@ -24,7 +24,7 @@ import { isIterable } from '../../../common/types.js';
import { CancellationToken, CancellationTokenSource } from '../../../common/cancellation.js';
import { IContextViewProvider } from '../contextview/contextview.js';
import { FuzzyScore } from '../../../common/filters.js';
import { splice } from '../../../common/arrays.js';
import { insertInto, splice } from '../../../common/arrays.js';
import { localize } from '../../../../nls.js';
interface IAsyncDataTreeNode<TInput, T> {
@ -1350,7 +1350,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
expanded.push(getId(node.element!.element as T));
}
stack.push(...node.children);
insertInto(stack, stack.length, node.children);
}
return { focus, selection, expanded, scrollTop: this.scrollTop };