perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Williams" <...@forum.swarthmore.edu>
Subject Re: cvs commit: modperl/lib/Apache PerlRun.pm
Date Mon, 29 Jan 2001 22:06:41 GMT
dougm@apache.org wrote:
>  --- PerlRun.pm	2001/01/12 15:45:12	1.34
>  +++ PerlRun.pm	2001/01/29 21:51:30	1.35
>  @@ -340,7 +340,12 @@
>           if (defined &$fullname) {
>               no warnings;
>               local $^W = 0;
>  -            *{$fullname} = sub {};
>  +            if (my $p = prototype $fullname) {
>  +                eval "*{\$fullname} = sub ($p) {}";
>  +            }
>  +            else {
>  +                *{$fullname} = sub {};
>  +            }
>   	    undef &$fullname;


I know it's a nitpick, but the following is a bit faster (about 35%
faster according to Benchmark) and a little clearer to read:

==========================================================
  --- PerlRun.pm	2001/01/12 15:45:12	1.34
  +++ PerlRun.pm	2001/01/29 21:51:30	1.35
  @@ -340,7 +340,12 @@
           if (defined &$fullname) {
               no warnings;
               local $^W = 0;
  -            *{$fullname} = sub {};
  +            if (my $p = prototype $fullname) {
  +                *{$fullname} = eval "sub ($p) {}";
  +            }
  +            else {
  +                *{$fullname} = sub {};
  +            }
   	    undef &$fullname;
   	}
           if (*{$fullname}{IO}) {
==========================================================

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum

Mime
View raw message