This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
diagnostics.pm: Eliminate $WHOAMI
authorFather Chrysostomos <sprout@cpan.org>
Sat, 8 Feb 2014 21:10:59 +0000 (13:10 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 9 Feb 2014 01:34:25 +0000 (17:34 -0800)
This variable only held the package name.  __PACKAGE__ is faster,
as it allows constant folding.

diagnostics.pm just happens to be older than __PACKAGE__, which was
introduced as recently as 1997 (68dc074516).

lib/diagnostics.pm

index d6a5caf..a85f282 100644 (file)
@@ -208,7 +208,6 @@ unshift @trypod, "./pod/perldiag.pod" if -e "pod/perldiag.pod";
 (my $PODFILE) = ((grep { -e } @trypod), $trypod[$#trypod])[0];
 
 $DEBUG ||= 0;
-my $WHOAMI = ref bless [];  # nobody's business, prolly not even mine
 
 local $| = 1;
 local $_;
@@ -238,7 +237,7 @@ CONFIG: {
 
     if (caller) {
        INCPATH: {
-           for my $file ( (map { "$_/$WHOAMI.pm" } @INC), $0) {
+           for my $file ( (map { "$_/".__PACKAGE__.".pm" } @INC), $0) {
                warn "Checking $file\n" if $DEBUG;
                if (open(POD_DIAG, $file)) {
                    while (<POD_DIAG>) {
@@ -450,7 +449,7 @@ my %msg;
             $transfmt{$header}{len} = length( $header );
        } 
 
-       print STDERR "$WHOAMI: Duplicate entry: \"$header\"\n"
+       print STDERR __PACKAGE__.": Duplicate entry: \"$header\"\n"
            if $msg{$header};
 
        $msg{$header} = '';
@@ -538,7 +537,7 @@ sub disable {
 
 sub warn_trap {
     my $warning = $_[0];
-    if (caller eq $WHOAMI or !splainthis($warning)) {
+    if (caller eq __PACKAGE__ or !splainthis($warning)) {
        if ($WARNTRACE) {
            print STDERR Carp::longmess($warning);
        } else {
@@ -563,7 +562,9 @@ sub death_trap {
     }
 
     splainthis($exception) unless $in_eval;
-    if (caller eq $WHOAMI) { print STDERR "INTERNAL EXCEPTION: $exception"; } 
+    if (caller eq __PACKAGE__) {
+       print STDERR "INTERNAL EXCEPTION: $exception";
+    } 
     &$olddie if defined $olddie and $olddie and $olddie ne \&death_trap;
 
     return if $in_eval;