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