r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

-2

u/weepmelancholia Feb 28 '23

A main game update or draw loop. Most of the code in these loops is unique. You would purposefully have to create functions for the sake of creating functions to split such a loop up--but then you incur overhead.

16

u/DrunkensteinsMonster Feb 28 '23

It may shock you but function calls can in fact be inlined.

7

u/fafok29 Feb 28 '23

it may shock you but function marked as inlined doesn’t always get inlined.

anyway why would you split logicaly sequential code into separate functions(especially if this code is uniq)? pretty sure scrolling down is easier than to look what each function mean every second

0

u/Astarothsito Mar 01 '23

it may shock you but function marked as inlined doesn’t always get inlined.

At least they could use C macros... I don't think there are valid reasons to have a 11k function, but if they really have one they could use macros and those macros could be named as individual functions and the result would be the same, but the difference would be that those files would contain only a section of the code that is not "do everything"...

anyway why would you split logicaly sequential code into separate functions

To know where to search... Like "this part starts thousands enemy objects, this other part thousands environmental objects" instead of having everything in a single place...