Code Duplication

Rolf Kalbermatter rolf.kalbermatter at citeng.com
Wed Feb 5 04:01:57 CST 2003


Matthew Davison <m.davison at virgin.net> wrote:

>During my work to clean up the Unicode -> ascii cross-calls I have
>noticed some A:W pairs where both are implemented in essentially the
>same way. Would it be sensible in these case to make the A function into
>a call to the W one, to reduce code size, or would I be wasting my time.

I have noticed the same, and looking through it I have for myself come to
the conclusion that if the function is rather simple, such as only calling
a few A/W specific WinAPIs there is no gain in trying to make the A function
call the W function other than an additional possible overhead in execution.
Just make sure both functions remain at the same position in the source so
that a prospective developer who patches one of the functions can't miss
the other one.
I for myself handle the rule: If the 'A calls W function with Unicode
translation' results in more lines of source code than the direct A
implementation I won't spend time to try to convert them.

If the function however is a little more complex there is always the issue
of maintaining two different functions in parallel and then making the A
function call the W function is the most sensible approach indeed.

Rolf Kalbermatter
 




More information about the wine-devel mailing list