remove Double#isFinite checks in Vec3 constructor

A performance analysis showed, that the Double#isFinite checks in the Vec3 constructor add significant overhead without providing much value to the application.
This commit is contained in:
jbb01 2024-08-04 19:54:21 +02:00
parent b47ded6c56
commit 07cdc0c213

View File

@ -11,9 +11,7 @@ public record Vec3(double x, double y, double z) {
public static final Vec3 UNIT_Z = new Vec3(0, 0, 1);
public Vec3 {
if (!Double.isFinite(x) || !Double.isFinite(y) || !Double.isFinite(z)) {
throw new IllegalArgumentException("x, y and z must be finite");
}
assert Double.isFinite(x) && Double.isFinite(y) && Double.isFinite(z) : "x, y and z must be finite";
}
public static @NotNull Vec3 random() {