Skip to content

Commit aad6a2e

Browse files
committed
Fix: Node/edge getter performance issue
1 parent e9133e5 commit aad6a2e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/models/edge.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,18 @@ abstract class Edge<N extends INodeBase, E extends IEdgeBase> extends Subject im
218218
}
219219

220220
getData(): E {
221-
return structuredClone(this._data);
221+
// no shallow/deep copy here due to the performance issues
222+
return this._data;
222223
}
223224

224225
getPosition(): IEdgePosition {
225-
return structuredClone(this._position);
226+
// no shallow/deep copy here due to the performance issues
227+
return this._position;
226228
}
227229

228230
getStyle(): IEdgeStyle {
229-
return structuredClone(this._style);
231+
// no shallow/deep copy here due to the performance issues
232+
return this._style;
230233
}
231234

232235
getState(): number {

src/models/node.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,18 @@ export class Node<N extends INodeBase, E extends IEdgeBase> extends Subject impl
182182
}
183183

184184
getData(): N {
185-
return structuredClone(this._data);
185+
// no shallow/deep copy here due to the performance issues
186+
return this._data;
186187
}
187188

188189
getPosition(): INodePosition {
189-
return structuredClone(this._position);
190+
// no shallow/deep copy here due to the performance issues
191+
return this._position;
190192
}
191193

192194
getStyle(): INodeStyle {
193-
return structuredClone(this._style);
195+
// no shallow/deep copy here due to the performance issues
196+
return this._style;
194197
}
195198

196199
getState(): number {

0 commit comments

Comments
 (0)