summaryrefslogtreecommitdiff
path: root/lib/warnings.pm
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-06-19 22:32:33 +0100
committerNicholas Clark <nick@ccl4.org>2010-06-23 08:44:42 +0100
commit4c02ac936e9cd63efc582d138cd258830b6e2e0c (patch)
treec882894b6bf85f212bf16642eb18e91ad96dc9da /lib/warnings.pm
parent8452af9f2d8674af680c1e3be7554590d5d7261c (diff)
downloadperl-4c02ac936e9cd63efc582d138cd258830b6e2e0c.tar.gz
Merge the guts of warnings::import and warnings::bits into _bits.
Additionally, removing the scope entry caused by the {} in the fast path of &import reduces instruction count and L1 cache misses for warnings->import() by 3%.
Diffstat (limited to 'lib/warnings.pm')
-rw-r--r--lib/warnings.pm46
1 files changed, 11 insertions, 35 deletions
diff --git a/lib/warnings.pm b/lib/warnings.pm
index c6881fecf5..3ea05e2b45 100644
--- a/lib/warnings.pm
+++ b/lib/warnings.pm
@@ -332,13 +332,8 @@ sub Croaker
Carp::croak(@_);
}
-sub bits
-{
- # called from B::Deparse.pm
-
- push @_, 'all' unless @_;
-
- my $mask;
+sub _bits {
+ my $mask = shift ;
my $catmask ;
my $fatal = 0 ;
my $no_fatal = 0 ;
@@ -364,6 +359,13 @@ sub bits
return $mask ;
}
+sub bits
+{
+ # called from B::Deparse.pm
+ push @_, 'all' unless @_ ;
+ return _bits(undef, @_) ;
+}
+
sub import
{
shift;
@@ -375,34 +377,8 @@ sub import
$mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1);
}
- unless (@_) {
- # This is equivalent to @_ = 'all' ;
- return ${^WARNING_BITS} = $mask | $Bits{all} ;
- }
-
- my $catmask ;
- my $fatal = 0 ;
- my $no_fatal = 0 ;
-
- foreach my $word ( @_ ) {
- if ($word eq 'FATAL') {
- $fatal = 1;
- $no_fatal = 0;
- }
- elsif ($word eq 'NONFATAL') {
- $fatal = 0;
- $no_fatal = 1;
- }
- elsif ($catmask = $Bits{$word}) {
- $mask |= $catmask ;
- $mask |= $DeadBits{$word} if $fatal ;
- $mask &= ~($DeadBits{$word}|$All) if $no_fatal ;
- }
- else
- { Croaker("Unknown warnings category '$word'")}
- }
-
- ${^WARNING_BITS} = $mask ;
+ # Empty @_ is equivalent to @_ = 'all' ;
+ ${^WARNING_BITS} = @_ ? _bits($mask, @_) : $mask | $Bits{all} ;
}
sub unimport