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
|
@ -124,6 +124,8 @@ export function GetDefaultEditorState(configuration: IConfiguration): IEditorSta
|
|||
null,
|
||||
mainContainerConfig
|
||||
);
|
||||
const containers = new Map<string, IContainerModel>();
|
||||
containers.set(mainContainer.properties.id, mainContainer);
|
||||
|
||||
const typeCounters = {};
|
||||
(typeCounters as any)[mainContainer.properties.type] = 0;
|
||||
|
@ -133,7 +135,8 @@ export function GetDefaultEditorState(configuration: IConfiguration): IEditorSta
|
|||
history: [
|
||||
{
|
||||
lastAction: '',
|
||||
mainContainer,
|
||||
mainContainer: mainContainer.properties.id,
|
||||
containers,
|
||||
selectedContainerId: mainContainer.properties.id,
|
||||
typeCounters,
|
||||
symbols: new Map(),
|
||||
|
@ -175,6 +178,13 @@ export const DEFAULT_CONFIG: IConfiguration = {
|
|||
/* eslint-enable */
|
||||
};
|
||||
|
||||
const DEFAULT_CONTAINER_STYLE = {
|
||||
stroke: 'black',
|
||||
fillOpacity: 1,
|
||||
fill: 'white',
|
||||
strokeWidth: 2
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Main container properties
|
||||
*/
|
||||
|
@ -203,10 +213,7 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
|
|||
showDimensionWithMarks: [Position.Down, Position.Right],
|
||||
markPosition: [],
|
||||
warning: '',
|
||||
style: {
|
||||
stroke: 'black',
|
||||
fillOpacity: 0
|
||||
}
|
||||
style: DEFAULT_CONTAINER_STYLE
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -256,7 +263,7 @@ export function GetDefaultContainerProps(type: string,
|
|||
showDimensionWithMarks: containerConfig.ShowDimensionWithMarks ?? [],
|
||||
warning: '',
|
||||
customSVG: containerConfig.CustomSVG,
|
||||
style: structuredClone(containerConfig.Style),
|
||||
style: Object.assign(structuredClone(DEFAULT_CONTAINER_STYLE), structuredClone(containerConfig.Style)),
|
||||
userData: structuredClone(containerConfig.UserData)
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue