Moved size determination out of loop.

Unnecessary repeated calls to a function returning the same value