So as long as it seems to work, wouldn't leaving it alone reduce the probability of introducing bugs?
If you don't understand the requirements, you likely don't understand the solution and potentially the problem either. In such circumstances it is best to either not intervene, or take the time to familiarize yourself with both the problem and the solution before you attempt to intervene.
I sometimes code out "in long' if I feel it is necessary. That is, I deliberately add extra lines to 'show my working'. As in, perhaps:
variable = foo( bar( baz( stuff )));
might possibly be laid out as bazzed = baz ( stuff ); /* comment one */
barred = bar ( bazzed ); /*comment two */
variable = foo ( barred ); /*comment three */
to show how and why a particular result is generated, if I feel the original code is too abstruse to see quickly why it is so.Yes, there is a (usually) negligible time cost in the running of the program that might even be fixed by an optimising compiler. But I will save a lot more time than that for myself and any other programmer in the future when maintenance time comes around.
BUT this is a sign and a lesson for you to improve your documentation.
You should be able to sit down with any code you have written and understand it by reading the comments.
IMHO: Any code that is NOT documented sufficiently that you can puck it up later is "Throw away code!"
If I need to add features to it I'll consider it though.
Either way I wouldn’t leave it as is, that’s just a recipe for ensuring it becomes even more opaque over time
Otherwise you have to concede that you're getting dumber. Someone better than you wrote code you don't understand, and it happened to be your younger self.
If it needs rewriting, I'll rewrite it.