Use indices for queue processing instead of Array.shift() (#236601)
* Use indices instead of Array.shift()
* 💄
pull/236607/head
parent
f990dfb385
commit
ffbf5a7f28
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue