It depends, what “messy code” means.
If you are computing unnecessary stuff, sure your code will run slower.
Also, using global variables is usually slower than local ones, but that probably shouldn’t make much a difference (of course it again depends what you are doing).
Could you explain your code a bit and what makes it messy?