5

Fine-Tuning the Code

I have stated repeatedly that the best way to improve code speed is to change the algorithm. Sometimes, however, this is just not possible because you already use the best possible algorithm. It may also be completely impractical, as changing the algorithm may require rewriting a large part of the program.

If this is the case and the code is still not running quickly enough, we have multiple available options. We can start optimizing the program, by which I mean that we can start changing small parts of the program and replacing them with faster code. This is the topic of this chapter.

Another option is to rewrite a part of the program in an assembler. Delphi offers quite decent support for this, and we’ll look into that ...

Get Delphi High Performance. - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.