Extreme (size) optimization in C, C++ and Objective-C.
by Krzysztof Kowalczyk
What is this about?
This document presents extreme techniques for optimizing the size of C, C++ and Objective-C programs. It’s about optimizing both the size of the final executable and the amount of memory used at runtime.
Sometimes the code will also become faster, although speed is not the main focus.
All examples come from optimizing real-life code.
Table of contents
- Why optimize?
- An optimization story
- Things you need to know
- Measuring size
- Asking the compiler to optimize for you
- Optimizing size of structures
- Optimizing arrays of structures
- Passing by value vs. passing by reference
- Allocating without freeing
- Smaller code through better architecture
- Case study: optimizing disassembler in v8
- Other misc ideas
Comments, corrections, suggestions? Send them to Krzysztof Kowalczyk