Skip to content

Use ArrayList instead of LinkedList for known size [SPR-16378] #20924

Closed
@spring-projects-issues

Description

@spring-projects-issues

Philippe Marschall opened SPR-16378 and commented

Spring JDBC unlike other modules uses LinkedList instead of ArrayList in several places. There is a large body of evidence suggesting that on contemporary hardware ArrayList is both faster and has less overhead than even in degenerate cases of empty lists [3] or unknown size.

There are two places in Spring JDBC where the size of the list is known in advance and an ArrayList of the correct final size can be created

[1] https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8011200
[2] http://cliffc.org/blog/2017/11/05/modern-hardware-performance-cache-lines/
[3] https://bugs.openjdk.java.net/browse/JDK-8011200


Affects: 4.3.13, 5.0.2

Referenced from: pull request #1643, and commits 64af3a0, 91e39d5

Backported to: 4.3.14

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions