aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

NullValue is now cached to avoid unnecessary object instantiations and improve performance #65

Closed jacinpoz closed 7 years ago

jacinpoz commented 7 years ago

I heavily use NullValues and I believe this pull request will help improving the overall performance of NullValue creation inside Value.java, as the logic of a NullValue object is always the same and allows us to cache it in a single instance. Less object allocation should also reduce garbage collection pressure.

This strategy is well known and is used in the Java ecosystem very frequently (e.g Collections.emptyList() or BigDecimal.ZERO), so this is not a novel or untested approach.

BrianNichols commented 7 years ago

Your pull request has been accepted. It will appear in the next java client release.

BrianNichols commented 7 years ago

Java client 3.3.1 has been released.

jacinpoz commented 7 years ago

Thanks!