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

Inefficient Usages of Java Collections #134

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

Conversation

FastAtlas
Copy link

@FastAtlas FastAtlas commented Sep 8, 2021

Hi,

We find that there are several inefficient usages of Java Collections:

  1. There is no iteration occurring upon a LinkedHashMap and a TreeMap, thus the insertion order does not matter. We recommend replacing the LinkedHashMap and the TreeMap with a HashMap.
  2. ArrayList is inserted before an iteration, while multiple memory reallocation might occur when the size of the list exceeds its capacity. We recommend replacing it with a LinkedList.

We discovered the above inefficient usages of containers by our tool Ditto. The patch is submitted. Could you please check and accept it? We have tested the patch on our PC. The patched program works well.

Bests

Ditto

@zhuyuqing zhuyuqing self-requested a review September 9, 2021 01:08
@zhuyuqing
Copy link
Collaborator

We highly welcome your contribution! Thank you!
However, we think that we need to double-check the performance of the corresponding data structures/classes, as well as further evaluating the performance influence due to the changes.
If it is convenient, your are welcomed to help us check the corresponding performance.

@iznauy iznauy self-requested a review September 9, 2021 02:53
FastAtlas and others added 2 commits September 9, 2021 10:58
@iznauy
Copy link
Contributor

iznauy commented Sep 9, 2021

Hi, thank you for your contribution! :D The majority of them are correct.

@FastAtlas
Copy link
Author

Hi, thank you for your contribution! :D The majority of them are correct.

So happy to accept your confirmation. Ditto did not consider the transformations of variable types. The transformations might introduce compile errors. We will improve Ditto and fix it.

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.

None yet

3 participants