9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

perf: avoid creating an ImmutableCollection copy every time updateCosmetics() is called

micro-optimizations, also we avoid calling Map#get again and using cosmetic.update(this) instead
This commit is contained in:
yusshu
2025-03-10 19:30:00 -05:00
parent 720437212b
commit 545f258f90

View File

@@ -315,7 +315,7 @@ public class CosmeticUser implements CosmeticHolder {
MessagesUtil.sendDebugMessages("updateCosmetic (All) - start");
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
for (Cosmetic cosmetic : getCosmetics()) {
for (Cosmetic cosmetic : playerCosmetics.values()) {
if (cosmetic instanceof CosmeticArmorType armorType) {
if (getUserEmoteManager().isPlayingEmote() || isInWardrobe()) return;
if (!(getEntity() instanceof HumanEntity humanEntity)) return;
@@ -327,7 +327,7 @@ public class CosmeticUser implements CosmeticHolder {
items.put(HMCCInventoryUtils.getEquipmentSlot(armorType.getSlot()), armorType.getItem(this));
} else {
updateCosmetic(cosmetic.getSlot());
cosmetic.update(this);
}
}
if (items.isEmpty() || getEntity() == null) return;