commons-math
commons-math copied to clipboard
Replace the inefficient Double constructor with static Double.valueOf() 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
Coverage remained the same at 89.963% when pulling 470da550681b0a8dbae294392eda557a91ce0345 on BruceKuiLiu:master-pullrequest into eafb16c711d5cd79edad5fbb2055252acdb3825e on apache:master.
Double.valueOf() is inefficient too. There should be used Double.doubleToLongBits(value1) == Double.doubleToLongBits(value2)