I'm currently reviewing a very old C++ project and see lots of code duplication there.
For example, there is a class with 5 MFC message handlers each holding 10 identical lines of code. Or there is a 5-line snippet for a very specific string transformation every here and there. Reducing code duplication is not a problem in these cases at all.
But I have a strange feeling that I might be misunderstanding something and that there was originally a reason for this duplication.
What could be a valid reason for duplicating code?