diff options
author | Alexdoru <57050655+Alexdoru@users.noreply.github.com> | 2024-09-16 01:12:03 +0200 |
---|---|---|
committer | boubou19 <miisterunknown@gmail.com> | 2024-09-17 22:55:46 +0200 |
commit | 730024055f670fef1fd4ba76b0863736a03fe227 (patch) | |
tree | 91ecc0fc2a99346ae7ee80ecbee2aa0d52eca6ef /src/main/java/ggfab | |
parent | d83cc53cf944772818eb1e23c065c54accaa0034 (diff) | |
download | GT5-Unofficial-730024055f670fef1fd4ba76b0863736a03fe227.tar.gz GT5-Unofficial-730024055f670fef1fd4ba76b0863736a03fe227.tar.bz2 GT5-Unofficial-730024055f670fef1fd4ba76b0863736a03fe227.zip |
cache some Enum.values() call to reduce RAM allocations
Diffstat (limited to 'src/main/java/ggfab')
-rw-r--r-- | src/main/java/ggfab/GigaGramFab.java | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/src/main/java/ggfab/GigaGramFab.java b/src/main/java/ggfab/GigaGramFab.java index 8fc8ef26a9..b13b789f40 100644 --- a/src/main/java/ggfab/GigaGramFab.java +++ b/src/main/java/ggfab/GigaGramFab.java @@ -2,7 +2,7 @@ package ggfab; import static gregtech.api.enums.ToolDictNames.*; import static gregtech.common.items.IDMetaTool01.*; -import static gregtech.common.items.MetaGeneratedTool01.*; +import static gregtech.common.items.MetaGeneratedTool01.INSTANCE; import net.minecraft.item.ItemStack; @@ -140,46 +140,43 @@ public class GigaGramFab { private void initDumbItem1() { GGMetaItemDumbItems i1 = new GGMetaItemDumbItems("ggfab.d1"); int id = 0; - { - int idShape = 30; - final int budget = idShape; - String prefix = "One_Use_craftingTool"; - String prefix2 = "Shape_One_Use_craftingTool"; - for (GGItemList i : GGItemList.values()) { - ItemStack stack = null; - if (i.name() - .startsWith(prefix)) { + int idShape = 30; + final int budget = idShape; + String prefix = "One_Use_craftingTool"; + String prefix2 = "Shape_One_Use_craftingTool"; + for (GGItemList i : GGItemList.values()) { + ItemStack stack = null; + if (i.name() + .startsWith(prefix)) { + stack = i1.addItem( + id++, + "Single Use " + GGUtils.processSentence( + i.name() + .substring(prefix.length()), + ' ', + true, + true), + null, + i, + i.name() + .substring("One_Use_".length())); + } else if (i.name() + .startsWith(prefix2)) { stack = i1.addItem( - id++, - "Single Use " + GGUtils.processSentence( + idShape++, + "Tool Casting Mold (" + GGUtils.processSentence( i.name() - .substring(prefix.length()), + .substring(prefix2.length()), ' ', true, - true), + true) + ")", null, - i, - i.name() - .substring("One_Use_".length())); - } else if (i.name() - .startsWith(prefix2)) { - stack = i1.addItem( - idShape++, - "Tool Casting Mold (" + GGUtils.processSentence( - i.name() - .substring(prefix2.length()), - ' ', - true, - true) + ")", - null, - i); - } - if (stack != null) { - i.set(stack); + i); } + if (stack != null) { + i.set(stack); } - if (id >= budget || idShape >= 2 * budget || idShape - id != budget) throw new AssertionError(); - id = budget * 2; } + if (id >= budget || idShape >= 2 * budget || idShape - id != budget) throw new AssertionError(); } } |