Skip to content
New issue

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

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

Already on GitHub? # to your account

refactor(getUID): improve performance and simplify logic #41159

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mmr-dev2008
Copy link

Description

This PR refactors the getUID function to improve its performance and simplify the code logic.
The function now uses a counter-based approach combined with a DOM uniqueness check, ensuring better performance and readability while maintaining backward compatibility.

Motivation & Context

The original getUID function relied heavily on random number generation, which could result in slower performance in environments with heavy DOM operations. By replacing random generation with a counter-based approach, the function is more efficient, predictable, and easier to understand.
This change was necessary to optimize ID generation in scenarios where a high volume of elements requires unique IDs.

Type of changes

  • Refactoring (non-breaking change)

Checklist

  • I have read the contributing guidelines.
  • My code follows the code style of the project (using npm run lint).
  • My change introduces changes to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Live previews

N/A (No visual changes introduced in this PR).

Related issues

N/A (No reported issues directly related to this change).

@mmr-dev2008 mmr-dev2008 requested a review from a team as a code owner January 17, 2025 19:09
@XhmikosR
Copy link
Member

Not sure we want the UUID to be predictable and I'd rather not change this without further people chiming in.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants