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

[Improvement]: Optimize BIRPackage.importModules to not contain duplicate BIRImportModule elements #42343

Open
Thushara-Piyasekara opened this issue Mar 19, 2024 · 0 comments · May be fixed by #42346
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Compilation

Comments

@Thushara-Piyasekara
Copy link
Contributor

Description

It is possible to optimize the BIRGen and Codegen phases by restricting the addition of duplicate BIRImportModule elements to the importModules attribute of BIRPackage.

As of now duplicate elements are added due to the usage of an ArrayList to hold the BIRImportModule elements.

image

Describe your problem(s)

These duplicate elements are being traversed by a for loop in the CodeGen phase,

image

This could create an unnecessary performance overhead for the compilation.

Describe your solution(s)

This process can be optimized by the usage of a HashSet instead of an ArrayList and setting up the necessary equals and hashCode functions for the BIRImportModule class. Which will prevent the addition of duplicate elements.

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Compilation
Projects
None yet
2 participants