NicMcPhee/CraftBukkit — pull request #6 by PhouLee (2014-04-30 23:34:46+00:00)
Title: Switch Statements Removed in CraftArt, CraftPotionEffectType, and CraftWorld

The Issue:
There were two methods in CraftArt.java that were using switch statements to generate MineCraft objects and CraftBukkit objects. These statements were long and repetitive.

There was one method in CraftPotionEffectType.java that had a switch statement. There was also another method in CraftWorld that also had a switch statement.

Justification:
This changes that we made improved readability and decreased the number of lines in the classes.

BreakDown:
We were able to remove both switch statements in NotchToBukkit() and BukkitToNotch(). We did by constructing a EnumMap Object to hold the Art objects as keys and the EnumArt objects as the values. NotchToBukkit uses the Map to get the keys while BukkitToNotch uses the Map to grab the values. This is faster than a switch statement when we grab the values in BukkitToNotch. However, this is about as fast as a switch statement when grabbing the keys.

We also removed switch statements in CraftPotionEffectType.getName() and CraftWorld.generateTree(). Was also used Map data structures here to remove the switch statement. In these two cases we only uses the Maps to get the values. Thus, it is faster than a switch statement. This made the methods not only faster but also improved readability.