NicMcPhee/CraftBukkit — pull request #2 by EmmaIreland (2014-04-18 22:40:19+00:00)
Title: Refactor CraftInventory split

The issue:
The methods splitStack and splitWithoutUpdate were largely the same, the main difference being that one updates the inventory.

Justification:
Duplicate code is an undesirable trait, as any potential changes to the methods have to be made in multiple places. It is also less clear that these two methods are logically similar.

Breakdown:
The bulk of the two methods was copied into a new helper method (splitHelper) that both split methods now call. They each pass in two integers and a boolean, which controls whether or not an update occurs.

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.