Merged PR 212: Optimize FindChildrenById from O(n) to O(1)
Optimize FindChildrenById from O(n) to O(1): - Deprecate FindContainerByIdDFS - Container: Replace Children to string[] - Add HashMap to IHistoryState that contains all containers To access a container by id now cost O(1) without any additional cost + Implement CICD for SVGLibs
This commit is contained in:
parent
466ef2b08b
commit
c256a76e01
45 changed files with 775 additions and 450 deletions
|
@ -32,15 +32,22 @@ export function ReviveState(state: IHistoryState): void {
|
|||
for (const symbol of state.symbols.values()) {
|
||||
symbol.linkedContainers = new Set(symbol.linkedContainers);
|
||||
}
|
||||
state.containers = new Map(state.containers);
|
||||
|
||||
const it = MakeDFSIterator(state.mainContainer);
|
||||
const root = FindContainerById(state.containers, state.mainContainer);
|
||||
|
||||
if (root === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const it = MakeDFSIterator(root, state.containers);
|
||||
for (const container of it) {
|
||||
const parentId = container.properties.parentId;
|
||||
if (parentId === null) {
|
||||
container.parent = null;
|
||||
continue;
|
||||
}
|
||||
const parent = FindContainerById(state.mainContainer, parentId);
|
||||
const parent = FindContainerById(state.containers, parentId);
|
||||
if (parent === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
@ -53,6 +60,10 @@ export function GetCircularReplacer(): (key: any, value: object | Map<string, an
|
|||
if (key === 'parent') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'containers') {
|
||||
return Array.from((value as Map<string, any>).entries());
|
||||
}
|
||||
|
||||
if (key === 'symbols') {
|
||||
return Array.from((value as Map<string, any>).entries());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue