From 730024055f670fef1fd4ba76b0863736a03fe227 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Mon, 16 Sep 2024 01:12:03 +0200 Subject: cache some Enum.values() call to reduce RAM allocations --- .../java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java | 2 +- .../gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/forestry') diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java index 05ab3c8711..73e01bac7a 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java @@ -69,7 +69,7 @@ public enum CustomCombs { public final int chance; private final String name; - private CustomCombs(String pName, boolean show, Materials material, int chance) { + CustomCombs(String pName, boolean show, Materials material, int chance) { this.name = pName; this.material = material; this.chance = chance; diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java index 0ff3625a25..e136b825e6 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java @@ -82,13 +82,12 @@ public class ItemCustomComb extends Item { @Override @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int pass) { - int meta = Math.max(0, Math.min(CustomCombs.values().length - 1, stack.getItemDamage())); - int colour = CustomCombs.values()[meta].getColours()[0]; - + final CustomCombs[] COMB_VALUES = CustomCombs.values(); + int meta = Math.max(0, Math.min(COMB_VALUES.length - 1, stack.getItemDamage())); + int colour = COMB_VALUES[meta].getColours()[0]; if (pass >= 1) { - colour = CustomCombs.values()[meta].getColours()[1]; + colour = COMB_VALUES[meta].getColours()[1]; } - return colour; } -- cgit