Skip to content

Commit b7f45f7

Browse files
reduce memory usage - avoid deep copy
1 parent a2d7f19 commit b7f45f7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

webview-ui/src/components/package-manager/PackageManagerViewStateManager.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,11 @@ export class PackageManagerViewStateManager {
8686
}
8787

8888
public getState(): ViewState {
89-
// Create a deep copy to ensure React sees changes
90-
return JSON.parse(JSON.stringify(this.state))
89+
return { ...this.state }
9190
}
9291

9392
private notifyStateChange(): void {
94-
// Create a deep copy to ensure React sees changes
95-
const newState = JSON.parse(JSON.stringify(this.state))
93+
const newState = { ...this.state }
9694

9795
this.stateChangeHandlers.forEach((handler) => {
9896
handler(newState)

0 commit comments

Comments
 (0)