Shouldn't this test be near the top of the function?  Or it this a micro-optimization?