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

Re: Speeding up mktables; NYTprof

Thread Previous | Thread Next
From:
Eirik Berg Hanssen
Date:
November 25, 2009 23:27
Subject:
Re: Speeding up mktables; NYTprof
Message ID:
7xljht9253.fsf@blackbox.eirik.dav
karl williamson <public@khwilliamson.com> writes:

> Based on looking at existing code in utf8_heavy.pl, 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
# constant.pm for an easy way to declare most constants.)


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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About