Skip to content

Commit

Permalink
(#393) shortcut multiplication if any of the operands is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
andi-huber committed Oct 18, 2023
1 parent 1721d8d commit c300a32
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,12 @@ private Number addWideAndNarrow(
private Number multiplyWideAndNarrow(
final NumberType wideType, final Number wide,
final NumberType narrowType, final Number narrow) {

// shortcut if any of the operands is zero.
if (wideType.isZero(wide)
|| narrowType.isZero(narrow)) {
return 0;
}

if(wideType.isIntegerOnly()) {
// at this point we know, that narrow must also be an integer-only type
Expand Down

0 comments on commit c300a32

Please sign in to comment.