googleapis / googleapis/google-http-java-client

Transform ArrayList to LinkedList for Performance Improvement

Aperta
#1,445 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
type: feature request
Lingua principale
Java
Stelle
1.4k
Fork
473
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.