Reuse variable value, return earlier.

This makes use of earlier computed variable instead of recomputing the value and also moves some of the computation down the code since it's not used if control returns early.