RAD Studio (Common)
ContentsIndex
PreviousUpNext
Optimization (Delphi)
Type  
Switch  
Syntax  
{$O+} or {$O-} {$OPTIMIZATION ON} or {$OPTIMIZATION OFF}  
Default  
{$O+} {$OPTIMIZATION ON}  
Scope  
Local  

The $O directive controls code optimization. In the {$O+} state, the compiler performs a number of code optimizations, such as placing variables in CPU registers, eliminating common subexpressions, and generating induction variables. In the {$O-} state, all such optimizations are disabled. 

Other than for certain debugging situations, you should never have a need to turn optimizations off. All optimizations performed by the Delphi compiler are guaranteed not to alter the meaning of a program. In other words, the compiler performs no "unsafe" optimizations that require special awareness by the programmer.

Note: Note: The $O directive can only turn optimization on or off for an entire procedure or function. You can't turn optimization on or off for a single line or group of lines within a routine.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!