I misread the code and thought the code kept looping until the mob spawn cap was hit. Upon furthur review, this is not true, so this patch doesn't do anything sane.
Apparently this was missed at some point, likely during the 1.9 update"