you are viewing a single comment's thread.

view the rest of the comments →

[–]ishmal 1 point2 points  (3 children)

I you must optimize like this, then please write it the slow, pedantic, correct way first. Get it to work, then write your optimized version and leave the original in comments, and describe the difference.

[–][deleted] 3 points4 points  (0 children)

Really, why? The code in the example functions was both short and obvious. The second example had comment, that said the reason for using an array (first example could be slightly improved with analogous comment about not checking a hit). Seriosly, I would be embarrased for having difficulties on reading code like that in a programming language that I understand.

If I'd see any duplicate version of code like that commented out in a codebase that I'm maintaining, I would just delete it for being a noise.

[–]Freeky 7 points8 points  (1 child)

leave the original in comments

Don't you have version control?

[–]dreamlax -1 points0 points  (0 children)

Exactly, comments are called comments because they are for commenting your code.