Skip to content
Success

Changes

Summary

  1. SPIGOT-7146: Reduce use of Material switch in ItemMeta (details)
Commit b7e9f1c8b9f103c9c186ab23532e332f242e6b78 by md_5
SPIGOT-7146: Reduce use of Material switch in ItemMeta

The Java compiler expands switch statements into a synthetic method that generates an int array with the enum's ordinal. For small enums this is fine, but with an enum as large as Material, this can add over one hundred thousand additional bytes of data. This unnecessarily increases CraftBukkit's overall file size by over 2MB. Where possible, simple conditions are returned. In cases where more than 2 constants are referenced, a HashSet is used (as opposed to an EnumSet which generates a large backing array into memory).
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCrossbow.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java
The file was modifiedsrc/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java