Re: Empty procedure optimized out?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tommy Carlier wrote:
> 
> Robert, couldn't you remove calls to empty procedures while parsing
> a program? I have a procedure to ignore the return value of a function,
> that looks like this:
> }}}
<eucode>
> global procedure ignore(object ignored)
> 	-- ignores its parameter
> end procedure
> </eucode>
{{{

> And it's used like this:
> }}}
<eucode>
> ignore(someFunction(someParameter1, someParameter2))
> </eucode>
{{{

> The function 'someFunction' should be executed, but the call to the
> empty procedure could be removed. That could also optimize this
> situation:
> }}}
<eucode>
> constant DEBUG = 0
> 
> procedure writeToLog(sequence line)
> 	if DEBUG then
> 		puts(logfile, line & '\n')
> 	end if
> end procedure
> </eucode>
{{{

> 
> 'if DEBUG then' can be removed, because you know before running the
> code than it will never be called. That makes the 'writeToLog'-procedure
> an empty procedure that can be optimized out.

Thanks. I'll add it to my list of possible optimizations.

By the way, this was too trivial for the release notes, 
but I took out the warning about parameters declared but not used.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu