-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip dirty stats copy when requesting player stats
There's literally only one getDirty call. Because the map was only retrieved once, we don't actually need to create a copy of the map just to iterate it, we can just access it directly and clear it manually after use.
- Loading branch information
1 parent
50c98cc
commit a93396e
Showing
3 changed files
with
48 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
patches/server/0009-Optimize-ServerStatsCounter-s-dirty-set.patch
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
patches/server/0009-Skip-dirty-stats-copy-when-requesting-player-stats.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: MrPowerGamerBR <[email protected]> | ||
Date: Wed, 22 Nov 2023 14:40:36 -0300 | ||
Subject: [PATCH] Skip dirty stats copy when requesting player stats | ||
|
||
There's literally only one getDirty call. Because the map was only retrieved once, we don't actually need to create a copy of the map just to iterate it, we can just access it directly and clear it manually after use. | ||
|
||
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java | ||
index 9bb8d4d7be6a937980aa653db82be084d066a563..e93722fd8b7a97037914beddbace9a0de5dca8b4 100644 | ||
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java | ||
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java | ||
@@ -85,12 +85,16 @@ public class ServerStatsCounter extends StatsCounter { | ||
this.dirty.add(stat); | ||
} | ||
|
||
+ // SparklyPaper start - Skip dirty stats copy when requesting player stats | ||
+ /* | ||
private Set<Stat<?>> getDirty() { | ||
Set<Stat<?>> set = Sets.newHashSet(this.dirty); | ||
|
||
this.dirty.clear(); | ||
return set; | ||
} | ||
+ */ | ||
+ // SparklyPaper end | ||
|
||
public void parseLocal(DataFixer dataFixer, String json) { | ||
try { | ||
@@ -238,7 +242,7 @@ public class ServerStatsCounter extends StatsCounter { | ||
|
||
public void sendStats(ServerPlayer player) { | ||
Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap(); | ||
- Iterator iterator = this.getDirty().iterator(); | ||
+ Iterator iterator = this.dirty.iterator(); // SparklyPaper - Skip dirty stats copy when requesting player stats | ||
|
||
while (iterator.hasNext()) { | ||
Stat<?> statistic = (Stat) iterator.next(); | ||
@@ -246,6 +250,8 @@ public class ServerStatsCounter extends StatsCounter { | ||
object2intmap.put(statistic, this.getValue(statistic)); | ||
} | ||
|
||
+ this.dirty.clear(); // SparklyPaper - Skip dirty stats copy when requesting player stats | ||
+ | ||
player.connection.send(new ClientboundAwardStatsPacket(object2intmap)); | ||
} | ||
} |