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