Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/clone object util to more performant and handle cyclic objects #15622

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

karliatto
Copy link
Member

Description

Replaces the util cloneObject with new that is more efficient and supports copying object with cyclic references instead of throwing error or missing the object. Adding also tests.

You can test the performance yourself with the code in gist: https://gist.github.com/karliatto/32c8b1b26f39f0b1fafb49318c760d7f

Copying 1000 objects results in:

  • Using stringify(parse): 4.92ms
  • Using WeakMap: 3.466ms

@mroz22
Copy link
Contributor

mroz22 commented Nov 28, 2024

I remember we there was some reason why we ended up using super stupid clone object (json stringify, json parse). But I don't remember details. 🤔

@karliatto
Copy link
Member Author

/rebase

Copy link

@trezor-ci trezor-ci force-pushed the feat/cloneObject-util-to-more-performant-and-handle-cyclic-objects branch from 633a43e to a3c7eb1 Compare November 28, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants