cwr_next():  move invariants out of loops.

This simplifies and clarifies the code, and gives a small speedup.
1 file changed