2:07:35Brian Q: Greetings
Casey. How do you find balancing duplicating code versus trying to generalize a function? As an exercise, I took FormatString() – from
Handmade Hero – and wrote a FormatWideString() version. In the end I chose to simply take the format, call UTF8FromUTF16(), call FormatString() on a temp buffer, then UTF16FromUTF8(). But now I sacrifice performance for maintenance. Other than if it becomes a bottleneck when profiling, what other things do you look for choosing to duplicate code and making it more a pain to maintain, than the benefits of having specific versions?
🗪
2:07:35Brian Q: Greetings
Casey. How do you find balancing duplicating code versus trying to generalize a function? As an exercise, I took FormatString() – from
Handmade Hero – and wrote a FormatWideString() version. In the end I chose to simply take the format, call UTF8FromUTF16(), call FormatString() on a temp buffer, then UTF16FromUTF8(). But now I sacrifice performance for maintenance. Other than if it becomes a bottleneck when profiling, what other things do you look for choosing to duplicate code and making it more a pain to maintain, than the benefits of having specific versions?
🗪
2:07:35Brian Q: Greetings
Casey. How do you find balancing duplicating code versus trying to generalize a function? As an exercise, I took FormatString() – from
Handmade Hero – and wrote a FormatWideString() version. In the end I chose to simply take the format, call UTF8FromUTF16(), call FormatString() on a temp buffer, then UTF16FromUTF8(). But now I sacrifice performance for maintenance. Other than if it becomes a bottleneck when profiling, what other things do you look for choosing to duplicate code and making it more a pain to maintain, than the benefits of having specific versions?
🗪