I have this idiot who wrote a function with the wonderfully descriptive name "IsABogusNeighbor". He wrote the function about 1.5 years ago. Ever since the function in question has been the bottleneck for certain large dimension computations I need.
After rewriting this idiot's code today (shortening it, like, twice), the program sped up by... let me illustrate: in the current example, the # of mathematical operations dropped from on average about 20 choose 10 (=184756) to on average about 2000. (The computational complexity dropped from n choose k to nk^2).
The worst part about all of this is that the idiot in question was me...
Not quite on the same vein, but I recently found a (mostly harmless) buffer overflow of 1 byte in two functions that are supposed to read big and little endian words from a binary buffer, that's been there for at least two years. What's worse is that at one point I noticed that their double word counterparts had the exact same bug, and apparently didn't bother to check the word versions. Chances are this time I've also left a similar bug unfixed.
And contrary to my expectations, most of the time spent rotating a graphic wasn't being spent on the linear transformation, despite the fact that it had always seemed like a really inefficient function to me. Remember, kids: always profile before optimizing.
I just had a bug (took me two+ hours to find) mostly due to bad naming of functions.
A funciton was called PopIndexSwapWithLast and another was called PopFirstOccurenceSwapWithLast. The two functions did exactly what their name says.
The biggest mistake I made was naming the functions so that they are next to one another in the autocomplete list, and so I managed to use one instead of the other in the wrong place.
Since the two functions very often happened to have the same end result, and were named so similarly, the bug was especially hard to notice.
man, i once made a function that gives to u the euler FI function of a number, and the first time i did it, i used miltiple iterations, dinamic arrays and what not.
then, i just took a good look at one piece of that code and relaized that i could have done most of the stuff in 1 iteration, so i made it that way, and guess what, 6/10 of the code just disappeared before my eyes, just like that, and dont make me even start how much efficient it is...