Skip to content

Commit

Permalink
Addressed review comments. Added more short circuits and remove unnee…
Browse files Browse the repository at this point in the history
…ded casts.
  • Loading branch information
chipkent committed Apr 16, 2024
1 parent 6fda5ad commit aea35f6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions engine/function/src/templates/Numeric.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ public class Numeric {
while ( vi.hasNext() ) {
final ${pt.primitive} c = vi.${pt.iteratorNext}();

if (isNaN(c)) {
if (isNaN(c) || isNaN(sum)) {
return Double.NaN;
}

Expand Down Expand Up @@ -1569,7 +1569,7 @@ public class Numeric {
while ( vi.hasNext() ) {
final ${pt.primitive} c = vi.${pt.iteratorNext}();

if (isNaN(c)) {
if (isNaN(c) || isNaN(prod)) {
return Double.NaN;
} else if (Double.isInfinite(c)) {
if (hasZero) {
Expand Down Expand Up @@ -1847,15 +1847,15 @@ public class Numeric {
while (vi.hasNext()) {
final ${pt.primitive} v = vi.${pt.iteratorNext}();

if (isNaN(v)) {
if (isNaN(v) || isNaN(result[i - 1])) {
Arrays.fill(result, i, n, Double.NaN);
return result;
} else if (isNull(result[i - 1])) {
result[i] = v;
} else if (isNull(v)) {
result[i] = result[i - 1];
} else {
result[i] = (double) (result[i - 1] + v);
result[i] = result[i - 1] + v;
}

i++;
Expand Down Expand Up @@ -1890,7 +1890,7 @@ public class Numeric {
} else if (isNull(v)) {
result[i] = result[i - 1];
} else {
result[i] = (long) (result[i - 1] + v);
result[i] = result[i - 1] + v;
}

i++;
Expand Down Expand Up @@ -1976,7 +1976,7 @@ public class Numeric {
} else if (isNull(v)) {
result[i] = result[i - 1];
} else {
result[i] = (double) (result[i - 1] * v);
result[i] = result[i - 1] * v;
}

i++;
Expand Down Expand Up @@ -2011,7 +2011,7 @@ public class Numeric {
} else if (isNull(v)) {
result[i] = result[i - 1];
} else {
result[i] = (long) (result[i - 1] * v);
result[i] = result[i - 1] * v;
}

i++;
Expand Down

0 comments on commit aea35f6

Please sign in to comment.