Skip to content

Commit

Permalink
Merge pull request #19 from fujiwara/fix-multi-use
Browse files Browse the repository at this point in the history
Fix for multiple use.
  • Loading branch information
Songmu committed May 9, 2019
2 parents c81bd0c + eed0819 commit 6abdcf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Devel/KYTProf.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use warnings;

our $VERSION = '0.9991';

my $Applied = {};

use Class::Data::Lite (
rw => {
namespace_regex => undef,
Expand Down Expand Up @@ -50,6 +52,7 @@ sub apply_prof {
unless ($prof_pkg->can('apply')) {
die qq{"$prof_pkg" has no `apply` method. A profiler package should implement it.\n};
}
return if ++$Applied->{$prof_pkg} > 1; # skip if already applied
$prof_pkg->apply(@args);
}

Expand Down
1 change: 1 addition & 0 deletions t/dbi.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use strict;
use warnings;
use Test::More;
use Devel::KYTProf;
use Devel::KYTProf; # test for multiple applied problem

use Test::Requires 'DBI', 'DBD::SQLite';

Expand Down

0 comments on commit 6abdcf2

Please sign in to comment.