Skip to content

Commit

Permalink
Fix: Node/edge getter performance issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIchenskiy committed Jul 12, 2024
1 parent e9133e5 commit aad6a2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/models/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,18 @@ abstract class Edge<N extends INodeBase, E extends IEdgeBase> extends Subject im
}

getData(): E {
return structuredClone(this._data);
// no shallow/deep copy here due to the performance issues
return this._data;
}

getPosition(): IEdgePosition {
return structuredClone(this._position);
// no shallow/deep copy here due to the performance issues
return this._position;
}

getStyle(): IEdgeStyle {
return structuredClone(this._style);
// no shallow/deep copy here due to the performance issues
return this._style;
}

getState(): number {
Expand Down
9 changes: 6 additions & 3 deletions src/models/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,18 @@ export class Node<N extends INodeBase, E extends IEdgeBase> extends Subject impl
}

getData(): N {
return structuredClone(this._data);
// no shallow/deep copy here due to the performance issues
return this._data;
}

getPosition(): INodePosition {
return structuredClone(this._position);
// no shallow/deep copy here due to the performance issues
return this._position;
}

getStyle(): INodeStyle {
return structuredClone(this._style);
// no shallow/deep copy here due to the performance issues
return this._style;
}

getState(): number {
Expand Down

0 comments on commit aad6a2e

Please sign in to comment.