
I recently refactored some signal processing code at work. My goal was to both make the code more maintainable as well as reverse engineer what it was doing. Most of the code was contained in a few large functions that could not be understood readily. I broke it up into many smaller functions that did one thing, keeping the code otherwise the same, and not only is it now easier to understand, but the compiler produced faster code. About 15 to 30 % reduction in runtime. (I verified the new code has exactly the same signal response as the old code.)
Amitai Schleier, Claes Wallin (韋嘉誠), Lars Wirzenius likes this.
Claes Wallin (韋嘉誠) shared this.

Testing and refactoring are often the best way to understand monolithic legacy code. Or the only way. I'm happy for you that you came out alive and enlightened on the other side. :-)
Claes Wallin (韋嘉誠) at 2015-04-16T15:14:22Z
X11R5, Charles Stanhope likes this.