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

perf(core): make classDeclaration validation more CPU efficient #582

Merged
merged 2 commits into from
Jan 5, 2023

Conversation

mttrbrts
Copy link
Member

@mttrbrts mttrbrts commented Jan 5, 2023

This change improves the algorithmic complexity of validating ClassDeclarations from O(n^2) to O(n). This gives a significant improvement for models with large numbers of class declarations.

Previously, we would compare each ClassDeclaration name with every other to detect duplicates. The implementation uses ES6's Set structure to more efficiently count duplicates.

Flags

  • We still use a more expensive lookup to find the name of duplicate (for use in the error message), but only in the case where there is a duplicate definition.

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

@mttrbrts mttrbrts marked this pull request as ready for review January 5, 2023 14:11
@mttrbrts mttrbrts requested a review from a team January 5, 2023 14:11
Signed-off-by: Matt Roberts <[email protected]>
@mttrbrts mttrbrts merged commit 760b078 into accordproject:main Jan 5, 2023
@mttrbrts mttrbrts deleted the mr-validate-perf branch January 5, 2023 16:15
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