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

Re: Speeding up mktables; NYTprof

Thread Previous | Thread Next
From:
karl williamson
Date:
November 26, 2009 07:47
Subject:
Re: Speeding up mktables; NYTprof
Message ID:
4B0EA2DD.8000600@khwilliamson.com
Eirik Berg Hanssen wrote:
> 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
I looked and actually it is that:
sub DEBUG () { 0 }  # Set to 0 for production; 1 for development

so it isn't getting optimized out, nonetheless.

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