Unless I missed something, these two functions are only called once. If you called the code of these two functions directly, i.e. without defining these two functions, your patch would be smaller and easier to uplift / backout.