C Code Optimization Techniques

Optimization is a coding activity. In traditional software development processes, optimization takes place after Code Complete, during the integration and testing phase of a project, when the performance of a whole program can be observed. In an Agile development process, one or more sprints may be allocated to optimization after a feature with performance goals is coded, or as needed to meet performance targets. The goal of optimization is to improve the behavior of a correct program so that it also meets customer needs for speed, throughput, memory footprint, power consumption, and so on. Optimization is thus as important to the development process as coding features are. …

Inline Function

Functions can be instructed to the compiler to make them inline so that the compiler can replace those function definitions wherever called. It saves the overhead of variable push/pop on the stack, which was required for function calling and also reduces the overhead of return from the function. At the same time, the inline function will tend to increase the code size.

Image for post
Image for post

Loop jamming

Loop jamming reduces code size and makes code run faster as well by eliminating the loop iteration overhead.

Image for post
Image for post

Riddhi Pandya

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store