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

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

Open
wants to merge 1 commit 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
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.

1 participant