No functional changes
Following changes have been made to make the code more readable
* added const where possible
* move variables closer to use
* rename abbreviated variables
* invert `if` and return early
Pull Request: https://projects.blender.org/blender/blender/pulls/113595