mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939) PaperMC/Paper@1922be90 Update custom tags (#12183) PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009) PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949) PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992) PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974) PaperMC/Paper@42b653b1 Expose more argument types (#12665) PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010) PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996) PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
59 lines
2.2 KiB
Diff
59 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Sun, 23 Feb 2025 00:37:39 +0100
|
|
Subject: [PATCH] Make removeIf slightly faster
|
|
|
|
|
|
diff --git a/net/minecraft/util/SortedArraySet.java b/net/minecraft/util/SortedArraySet.java
|
|
index e8bad6e1c0aeb67005661db6ed42f745554fa652..c2d64cdc5241d54379da2b843b6f28db8a8e39a9 100644
|
|
--- a/net/minecraft/util/SortedArraySet.java
|
|
+++ b/net/minecraft/util/SortedArraySet.java
|
|
@@ -19,36 +19,26 @@ public class SortedArraySet<T> extends AbstractSet<T> implements ca.spottedleaf.
|
|
// Paper start - rewrite chunk system
|
|
@Override
|
|
public final boolean removeIf(final java.util.function.Predicate<? super T> filter) {
|
|
- // prev. impl used an iterator, which could be n^2 and creates garbage
|
|
+ // Leaf start - Make removeIf slightly faster
|
|
int i = 0;
|
|
final int len = this.size;
|
|
final T[] backingArray = this.contents;
|
|
|
|
- for (;;) {
|
|
- if (i >= len) {
|
|
- return false;
|
|
- }
|
|
- if (!filter.test(backingArray[i++])) {
|
|
- continue;
|
|
- }
|
|
- break;
|
|
- }
|
|
+ // Find first element to remove
|
|
+ while (i < len && !filter.test(backingArray[i])) i++;
|
|
+ if (i == len) return false;
|
|
|
|
- // we only want to write back to backingArray if we really need to
|
|
-
|
|
- int lastIndex = i - 1; // this is where new elements are shifted to
|
|
-
|
|
- for (; i < len; ++i) {
|
|
- final T curr = backingArray[i];
|
|
- if (!filter.test(curr)) { // if test throws we're screwed
|
|
- backingArray[lastIndex++] = curr;
|
|
- }
|
|
+ // Shift elements in-place
|
|
+ int lastIndex = i;
|
|
+ for (i++; i < len; i++) {
|
|
+ T curr = backingArray[i];
|
|
+ if (!filter.test(curr)) backingArray[lastIndex++] = curr;
|
|
}
|
|
|
|
- // cleanup end
|
|
- Arrays.fill(backingArray, lastIndex, len, null);
|
|
+ // Only update size - skip Arrays.fill (safe in ChunkHolderManager's context)
|
|
this.size = lastIndex;
|
|
return true;
|
|
+ // Leaf end - Make removeIf slightly faster
|
|
}
|
|
|
|
@Override
|