I have to update a legacy application for a critical bug fix. I have to mention upfront that the code i am maintaining is rather bad and numerous mistakes were made that results in performance penalties. The linked-list is implemented rather badly and in some instances incorrectly. The problem goes from bad to worse where core code in the module was cut and pasted to write other components in the system.
Should I re-implement some elements using c++ generics fixing and as much of the good stuff as possible? Or should I keep code change to a minimum? Should I rather choose to patch the code as best I can without re-writing? Either way the work I am performing will be substantial and has a major impact on the system; and this is understood, so full regression testing will be performed.