Let's get one thing straight - there's a huge difference between:
1. Badly written code
AND
2. Well-written code that looks bad
In case 1, the code is badly written so that there are more queries, it is inefficient etc.
In case 2, the code works well, but just looks bad - ie. it's not formatted nicely in separate lines with comments.
If we are talking about case 1, I say, go for it, try to optimize badly written code.
If we are talking about case 2, then I would say that is up to individual preference - for example, if and when I release a hack, it's because I've usually written it for my own site, so I'm not going to waste too much time formatting it "to look nice".
So let's decide - are we talking about function or about "looks".