NicMcPhee/CraftBukkit — pull request #5 by EmmaIreland (2014-04-23 01:20:10+00:00)
Title: Converted the if/else block in getType() to a series of helper methods.

The issue:
There was a large if/else block in getType(). It was exclusively an if/else block that checked types of inventory.

Justification:
This method can introduce inefficiencies because the cases are always checked in the same order (by necessity). By allowing the compiler to take care of figuring out which type of IInventory is being passed in, we reduce overhead.

Breakdown:
The cases in the if/else block were separated and put into smaller helper methods. Each method took a different type of inventory and the body of the method was determined by the body of the corresponding if-statement.

Testing:
Unfortunately there are no existing tests that cover this code. However it is a relatively simple refactoring, and we are confident that it still functions correctly.