then yes the compiler likely will optimize away the while.
I find it doesn't, I use that construct all the time.