googleapis / googleapis/google-http-java-client
Transform ArrayList to LinkedList for Performance Improvement
- 主要语言
- Java
- 星标
- 1.4k
- 派生
- 473
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hi,
We find that there are several ArrayList objects which are not manipulated by random access. Due to the memory reallocation triggered in the successive insertions, the time complexity of add method of ArrayList is amortized O(1). We notice that these objects are only used for traversal and the retrieval for the first or the last element.
This functionality can be implemented by LinkedList. Moreover, the insertion of LinkedList is strictly O(1) time complexity because no memory reallocation occurs.
We discovered this inefficient usage of containers by our tool Ditto. The patch is submitted in #1444. Could you please check and accept it? We have tested the patch on our PC. The patched program works well.
Bests
Ditto
贡献指南
评估
这个 Issue 还没有评估数据。