-
Enhancement
-
Resolution: Duplicate
-
P3
-
6-pool
-
generic
-
generic
BigDecimal.subtract(BigDecimal subtrahend) is currently implemented as:
public BigDecimal subtract(BigDecimal subtrahend) {
return add(subtrahend.negate());
}
subtrahend.negate() produces a new BigDecimal object since BigDecimal objects are immutable.
This object allocation could be avoided by providing a "pure" implementation of subtract, similar to the "pure" implementation of BigDecimal.add(BigDecimal augend).
A prototype of a "pure" BigDecimal.subtract(BigDecimal subtrahend) suggests an improvement of 1% - 2% in SPECjbb2005 performance on some hardware platforms.
public BigDecimal subtract(BigDecimal subtrahend) {
return add(subtrahend.negate());
}
subtrahend.negate() produces a new BigDecimal object since BigDecimal objects are immutable.
This object allocation could be avoided by providing a "pure" implementation of subtract, similar to the "pure" implementation of BigDecimal.add(BigDecimal augend).
A prototype of a "pure" BigDecimal.subtract(BigDecimal subtrahend) suggests an improvement of 1% - 2% in SPECjbb2005 performance on some hardware platforms.