Those comments suggest that count() is unreliable. At the least, it's unnecessary - the code I posted above should cover all the bases.