IginX icon indicating copy to clipboard operation
IginX copied to clipboard

Inefficient Usages of Java Collections

Open FastAtlas opened this issue 3 years ago • 3 comments

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

FastAtlas avatar Sep 08 '21 10:09 FastAtlas

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.

zhuyuqing avatar Sep 09 '21 01:09 zhuyuqing

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

iznauy avatar Sep 09 '21 03:09 iznauy

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.

FastAtlas avatar Sep 09 '21 03:09 FastAtlas