Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 16022, Elimination (Optimization) of call to empty procedure

by Mahadeo Naig Email: mahadeo@hotmail.com


When a call is made to a procedure that does nothing, the call must be eliminated by the compiler.
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 1.0  to 6.0 23 downloads
Copyright: No significant restrictions


Size: 0 bytes
Updated on Tue, 01 May 2001 10:05:08 GMT
Originally uploaded on Tue, 01 May 2001 10:05:08 GMT
Description
Consider the below code

procedure Callee();
begin
{$IFNDEF NODEBUG}
if FCanLogDebug then
SaveEvent('D', sDebug);
{$ENDIF}
end;

procedure Caller()
begin
Callee();
end;

even when NODEBUG is defined, the compiler produces code in Caller() to setup the stack and call Callee. Callee also has about 15 assembly line instructions although it does nothing. Both the call and the procedure can be eliminated.

The way I am using this. The whole application uses a LoggingAgent which supplies services for categorized logging. One of the categories is Debug and I want to use the IFNDEF NODEBUG to eliminate this code. The alternative is; all calls to LogDebug should be enclosed in compiler directives... which is quite a bit of work

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04