Transform ArrayList to LinkedList for Performance Improvement

未关闭
#1,445 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
performance

调研方向

首先检查 #1444 引用的补丁以及受影响的 ArrayList 用法。确认每一处仅用于遍历或获取第一个/最后一个元素,并确认建议转换为 LinkedList 后仍能保持行为不变;完成标准是接受该补丁。

由索引模型根据 Issue 内容生成。

描述

type: feature request

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

主要语言
Java
星标
1.4k
派生
476
平均合并
10 小时 47 分钟
30 天内合并 PR
3

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleapis/google-http-java-client 的其他 Issue

查看 googleapis/google-http-java-client 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。