I would say that it is not quite right to say that code optimisation is ill advised. What is not advised is pre-optimisation!
It is an often recommended process to hit the white board (or brain storm, or put it on paper; different terms pointing to the same concept) before you begin the actual process of writing code. This will allow you to think through any potential bottlenecks that you would have to tackle, and help you sketch out a spec for the module of code you are about to write so that it's interoperable with other modules/parts of your codebase.
Anything on top of the above (including further optimisation, of course after a "profile" proof which would deem the optimisation sensible) should be, in my opinion, an after thought; after you have actual code that works as intended. This is usually done through a self/team code review process!
I've written a super short brief of the process in an earlier article (where we optimised some code involving JS arrays using Array#reduce)
As Addy Osmani had put it:
First do it, then do it right, then do it better!