Silence sign-compare warning and reduce nesting.

No functionality change.