mirror of
https://github.com/PaperMC/Paper.git
synced 2025-04-02 12:37:20 +02:00
Also check class loader cache before locking to speed up cached hits to avoid the lock wasn't gonna make a unique build just for that but can lump it in here.
57 lines
No EOL
2.3 KiB
Diff
57 lines
No EOL
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
Date: Mon, 6 Apr 2020 18:35:09 -0700
|
|
Subject: [PATCH] Reduce Either Optional allocation
|
|
|
|
In order to get chunk values, we shouldn't need to create
|
|
an optional each time.
|
|
|
|
diff --git a/src/main/java/com/mojang/datafixers/util/Either.java b/src/main/java/com/mojang/datafixers/util/Either.java
|
|
index a90adac7b..4bb621d57 100644
|
|
--- a/src/main/java/com/mojang/datafixers/util/Either.java
|
|
+++ b/src/main/java/com/mojang/datafixers/util/Either.java
|
|
@@ -0,0 +0,0 @@ public abstract class Either<L, R> implements App<Either.Mu<R>, L> {
|
|
}
|
|
|
|
private static final class Left<L, R> extends Either<L, R> {
|
|
- private final L value;
|
|
+ private final L value; private final Optional<L> valueOptional; // Paper - reduce the optional allocation...
|
|
|
|
public Left(final L value) {
|
|
- this.value = value;
|
|
+ this.value = value; this.valueOptional = value != null ? Optional.of(value) : Optional.empty(); // Paper - reduce the optional allocation...
|
|
}
|
|
|
|
@Override
|
|
@@ -0,0 +0,0 @@ public abstract class Either<L, R> implements App<Either.Mu<R>, L> {
|
|
|
|
@Override
|
|
public Optional<L> left() {
|
|
- return Optional.of(value);
|
|
+ return this.valueOptional; // Paper - reduce the optional allocation...
|
|
}
|
|
|
|
@Override
|
|
@@ -0,0 +0,0 @@ public abstract class Either<L, R> implements App<Either.Mu<R>, L> {
|
|
}
|
|
|
|
private static final class Right<L, R> extends Either<L, R> {
|
|
- private final R value;
|
|
+ private final R value; private final Optional<R> valueOptional; // Paper - reduce the optional allocation...
|
|
|
|
public Right(final R value) {
|
|
- this.value = value;
|
|
+ this.value = value; this.valueOptional = value != null ? Optional.of(value) : Optional.empty(); // Paper - reduce the optional allocation...
|
|
}
|
|
|
|
@Override
|
|
@@ -0,0 +0,0 @@ public abstract class Either<L, R> implements App<Either.Mu<R>, L> {
|
|
|
|
@Override
|
|
public Optional<R> right() {
|
|
- return Optional.of(value);
|
|
+ return this.valueOptional; // Paper - reduce the optional allocation...
|
|
}
|
|
|
|
@Override
|
|
--
|