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.
main
jbb01 6 months ago
parent b47ded6c56
commit 07cdc0c213

@ -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 static final Vec3 UNIT_Z = new Vec3(0, 0, 1);
public Vec3 { public Vec3 {
if (!Double.isFinite(x) || !Double.isFinite(y) || !Double.isFinite(z)) { assert Double.isFinite(x) && Double.isFinite(y) && Double.isFinite(z) : "x, y and z must be finite";
throw new IllegalArgumentException("x, y and z must be finite");
}
} }
public static @NotNull Vec3 random() { public static @NotNull Vec3 random() {

Loading…
Cancel
Save