mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-29 11:59:24 +00:00
[ci skip] cleanup
This commit is contained in:
@@ -5,23 +5,10 @@ Subject: [PATCH] Optimize ContextMap.create
|
||||
|
||||
|
||||
diff --git a/net/minecraft/util/context/ContextMap.java b/net/minecraft/util/context/ContextMap.java
|
||||
index cc8d67df5e074beb8c41bb6ce4f519f963e59d0d..9b1152db265afd87f17f0b7d4b2d09f4913b2f9c 100644
|
||||
index cc8d67df5e074beb8c41bb6ce4f519f963e59d0d..64a48913868d9b8c0a4bb3f97458a64c95e99034 100644
|
||||
--- a/net/minecraft/util/context/ContextMap.java
|
||||
+++ b/net/minecraft/util/context/ContextMap.java
|
||||
@@ -1,10 +1,8 @@
|
||||
package net.minecraft.util.context;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
-import java.util.IdentityHashMap;
|
||||
-import java.util.Map;
|
||||
-import java.util.NoSuchElementException;
|
||||
-import java.util.Set;
|
||||
+
|
||||
+import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
@@ -72,17 +70,39 @@ public class ContextMap {
|
||||
@@ -72,17 +72,41 @@ public class ContextMap {
|
||||
}
|
||||
|
||||
public ContextMap create(ContextKeySet contextKeySet) {
|
||||
@@ -34,6 +21,7 @@ index cc8d67df5e074beb8c41bb6ce4f519f963e59d0d..9b1152db265afd87f17f0b7d4b2d09f4
|
||||
- throw new IllegalArgumentException("Missing required parameters: " + set1);
|
||||
- } else {
|
||||
- return new ContextMap(this.params);
|
||||
+ // Leaf start - Optimize ContextMap.create
|
||||
+ Set<ContextKey<?>> allowed = contextKeySet.allowed();
|
||||
+ Set<ContextKey<?>> invalid = null;
|
||||
+
|
||||
@@ -41,11 +29,11 @@ index cc8d67df5e074beb8c41bb6ce4f519f963e59d0d..9b1152db265afd87f17f0b7d4b2d09f4
|
||||
+ for (ContextKey<?> key : this.params.keySet()) {
|
||||
+ if (!allowed.contains(key)) {
|
||||
+ if (invalid == null) {
|
||||
+ invalid = new HashSet<>();
|
||||
+ invalid = new java.util.HashSet<>();
|
||||
+ }
|
||||
+ invalid.add(key);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+ if (invalid != null) {
|
||||
+ throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + invalid);
|
||||
+ }
|
||||
@@ -57,16 +45,17 @@ index cc8d67df5e074beb8c41bb6ce4f519f963e59d0d..9b1152db265afd87f17f0b7d4b2d09f4
|
||||
+ for (ContextKey<?> reqKey : required) {
|
||||
+ if (!this.params.containsKey(reqKey)) {
|
||||
+ if (missing == null) {
|
||||
+ missing = new HashSet<>();
|
||||
+ missing = new java.util.HashSet<>();
|
||||
+ }
|
||||
+ missing.add(reqKey);
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
+ if (missing != null) {
|
||||
+ throw new IllegalArgumentException("Missing required parameters: " + missing);
|
||||
+ }
|
||||
+
|
||||
+ return new ContextMap(this.params);
|
||||
+ // Leaf end - Optimize ContextMap.create
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user