I sometimes feel I code better when I'm slightly mentally impaired, because my mind stops getting in the way of getting things done and over analyzing problems.
But then I'm very rarely mentally impaired, as I normally neither drink nor consume cannabis or anything like that, so idk.
EDIT: Oh, just realized the answer is probably simple => less stress.