Removing comparison with java performance for while loops