mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 02:49:19 +00:00
Originally vanilla logic is to use stream, and Mojang switched it to Guava's Collections2 since 1.21.4. It is much faster than using stream or manually adding to a new ArrayList. Manually adding to a new ArrayList requires allocating a new object array. However, the Collections2 lazy handles filter condition on iteration, so much better.
29 lines
1.9 KiB
Diff
29 lines
1.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
|
Subject: [PATCH] Replace EntitySelectorOptions map with optimized collection
|
|
|
|
|
|
diff --git a/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java b/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java
|
|
index 3b945ac061f192b09dd86e8627dacf11b190d2d9..9e2fd3684260fad1d94a795cb5617c5ccc231adc 100644
|
|
--- a/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java
|
|
+++ b/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java
|
|
@@ -357,7 +357,7 @@ public class EntitySelectorOptions {
|
|
}, entitySelectorParser -> true, Component.translatable("argument.entity.options.nbt.description"));
|
|
register("scores", parser -> {
|
|
StringReader reader = parser.getReader();
|
|
- Map<String, MinMaxBounds.Ints> map = Maps.newHashMap();
|
|
+ it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<String, MinMaxBounds.Ints> map = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // Leaf - Replace options map with optimized collection
|
|
reader.expect('{');
|
|
reader.skipWhitespace();
|
|
|
|
@@ -380,7 +380,7 @@ public class EntitySelectorOptions {
|
|
parser.addPredicate(entity -> {
|
|
Scoreboard scoreboard = entity.getServer().getScoreboard();
|
|
|
|
- for (Entry<String, MinMaxBounds.Ints> entry : map.entrySet()) {
|
|
+ for (Entry<String, MinMaxBounds.Ints> entry : map.object2ObjectEntrySet()) { // Leaf - Replace options map with optimized collection
|
|
Objective objective = scoreboard.getObjective(entry.getKey());
|
|
if (objective == null) {
|
|
return false;
|