--- a/com/mojang/datafixers/util/Either.java +++ b/com/mojang/datafixers/util/Either.java @@ -22,7 +_,7 @@ } private static final class Left extends Either { - private final L value; + private final L value; private Optional valueOptional; // Paper - Perf: Reduce Either Optional allocation public Left(final L value) { this.value = value; @@ -51,7 +_,7 @@ @Override public Optional left() { - return Optional.of(value); + return this.valueOptional == null ? this.valueOptional = Optional.of(this.value) : this.valueOptional; // Paper - Perf: Reduce Either Optional allocation } @Override @@ -83,7 +_,7 @@ } private static final class Right extends Either { - private final R value; + private final R value; private Optional valueOptional; // Paper - Perf: Reduce Either Optional allocation public Right(final R value) { this.value = value; @@ -117,7 +_,7 @@ @Override public Optional right() { - return Optional.of(value); + return this.valueOptional == null ? this.valueOptional = Optional.of(this.value) : this.valueOptional; // Paper - Perf: Reduce Either Optional allocation } @Override