develooper Front page | perl.perl5.porters | Postings from November 2009

Re: Speeding up mktables; NYTprof

Thread Previous | Thread Next
Eirik Berg Hanssen
November 25, 2009 23:27
Re: Speeding up mktables; NYTprof
Message ID:
karl williamson <> writes:

> Based on looking at existing code in, I had presumed
> that the Perl optimizer would remove code that depended on a constant
> subroutine that returns false.  That is, 'foo if DEBUG' would be
> optimized away if there was a line: 'sub Debug { 0 }'  But that
> appears to not be the case.

  It needs a prototype: 'sub Debug () { 0 }'.

  From perlsub:

# Functions with a prototype of "()" are potential candidates for
# inlining.  If the result after optimization and constant folding is
# either a constant or a lexically‚Äźscoped scalar which has no other
# references, then it will be used in place of function calls made
# without "&".  Calls made using "&" are never inlined.  (See
# for an easy way to declare most constants.)

All bridge hands are equally likely, but some are more equally likely
than others.
                -- Alan Truscott

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About