Skip to content

Conversation

@Kui-Liu
Copy link

@Kui-Liu Kui-Liu commented Oct 9, 2017

Using new Double(double) is guaranteed to always result in a new object whereas Double.valueOf(double) allows caching of values to be done by the compiler, class library, or JVM.
Using of cached values avoids object allocation and the code will be faster.
http://findbugs.sourceforge.net/bugDescriptions.html#DM_FP_NUMBER_CTOR

…() method.

Using new Double(double) is guaranteed to always result in a new object whereas Double.valueOf(double) allows caching of values to be done by the compiler, class library, or JVM.
Using of cached values avoids object allocation and the code will be faster.
http://findbugs.sourceforge.net/bugDescriptions.html#DM_FP_NUMBER_CTOR
@coveralls
Copy link

Coverage Status

Coverage remained the same at 89.963% when pulling 470da55 on BruceKuiLiu:master-pullrequest into eafb16c on apache:master.

@jandam
Copy link

jandam commented Nov 19, 2017

Double.valueOf() is inefficient too. There should be used Double.doubleToLongBits(value1) == Double.doubleToLongBits(value2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants