aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2022-09-12 13:31:45 +0200
committerNassim Jahnke <[email protected]>2022-09-12 13:31:45 +0200
commitef0e5a642d33ac62f070c45a61cb42647b2744cd (patch)
tree70dff1b36e6d4306f059b3c8e335527af00adf73 /patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch
parent51183af967aafb3d57dc19421da1bcb0aea9d3d2 (diff)
downloadPaper-ef0e5a642d33ac62f070c45a61cb42647b2744cd.tar.gz
Paper-ef0e5a642d33ac62f070c45a61cb42647b2744cd.zip
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9ae3f10f SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API 48c0c547 PR-786: Add methods to get sounds from entities CraftBukkit Changes: 5cc9c022a SPIGOT-7152: Handle hand item changing during air interact event 4ffa1acf6 SPIGOT-7154: Players get kicked when interacting with a conversation 4daa21123 SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API e5d6a9bbf PR-1100: Add methods to get sounds from entities b7e9f1c8b SPIGOT-7146: Reduce use of Material switch in ItemMeta Spigot Changes: 4c157bb4 Rebuild patches
Diffstat (limited to 'patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch')
-rw-r--r--patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch b/patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch
new file mode 100644
index 0000000000..0763953dd5
--- /dev/null
+++ b/patches/server/0465-Optimize-the-advancement-data-player-iteration-to-be.patch
@@ -0,0 +1,54 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Wyatt Childers <[email protected]>
+Date: Sat, 4 Jul 2020 23:07:43 -0400
+Subject: [PATCH] Optimize the advancement data player iteration to be O(N)
+ rather than O(N^2)
+
+
+diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
+index 3f7f6a43ac0bf2efb0e66dc96438febbd92113e9..0c2f12e7930646a3da53a50f38be62e0cb1ed2b7 100644
+--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
++++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
+@@ -435,6 +435,16 @@ public class PlayerAdvancements {
+ }
+
+ private void ensureVisibility(Advancement advancement) {
++ // Paper start
++ ensureVisibility(advancement, IterationEntryPoint.ROOT);
++ }
++ private enum IterationEntryPoint {
++ ROOT,
++ ITERATOR,
++ PARENT_OF_ITERATOR
++ }
++ private void ensureVisibility(Advancement advancement, IterationEntryPoint entryPoint) {
++ // Paper end
+ boolean flag = this.shouldBeVisible(advancement);
+ boolean flag1 = this.visible.contains(advancement);
+
+@@ -450,15 +460,23 @@ public class PlayerAdvancements {
+ }
+
+ if (flag != flag1 && advancement.getParent() != null) {
+- this.ensureVisibility(advancement.getParent());
++ // Paper start - If we're not coming from an iterator consider this to be a root entry, otherwise
++ // market that we're entering from the parent of an iterator.
++ this.ensureVisibility(advancement.getParent(), entryPoint == IterationEntryPoint.ITERATOR ? IterationEntryPoint.PARENT_OF_ITERATOR : IterationEntryPoint.ROOT);
+ }
+
++ // If this is true, we've went through a child iteration, entered the parent, processed the parent
++ // and are about to reprocess the children. Stop processing here to prevent O(N^2) processing.
++ if (entryPoint == IterationEntryPoint.PARENT_OF_ITERATOR) {
++ return;
++ } // Paper end
++
+ Iterator iterator = advancement.getChildren().iterator();
+
+ while (iterator.hasNext()) {
+ Advancement advancement1 = (Advancement) iterator.next();
+
+- this.ensureVisibility(advancement1);
++ this.ensureVisibility(advancement1, IterationEntryPoint.ITERATOR); // Paper - Mark this call as being from iteration
+ }
+
+ }