First post, by keenmaster486
- Rank
- l33t
This is all in Open Watcom C++ 16 bit.
Examples of things I have done that have inexplicably inflated the size of the executable by inexcusable amounts:
- Creating pointers to dynamically allocated instances of a class, inside of a function (can skyrocket the executable size, adding about 1-2K per instance, despite them all being allocated AT RUNTIME, NOT COMPILE TIME. If I do it in a for loop, the executable size does NOT increase, which is why I know this DOES NOT HAVE TO HAPPEN. Does the compiler literally create multiple copies of the class methods for each instance instead of using the same code and passing a different pointer for "this"? Dumbest thing I've ever seen. I hate it.)
- Adding a single if block with a single function call and a return statement (adds 2K)
- Multiplying a constant by 1.5 instead of performing ((constant/2) + constant) - adds 20K (!!!)
These are just the ones I've discovered. I'm sure my executable could be reduced by dozens of KB if INSANE compiler behaviors like "add 2K for no reason because you added a single trivial if statement" didn't exist.
World's foremost 486 enjoyer.