Author: tim.bunce
Date: Sat May 9 15:22:10 2009
New Revision: 745
Modified:
trunk/HACKING
trunk/lib/Devel/NYTProf/SubInfo.pm
Log:
Avoid undef warnings where subs have no known line numbers (eg Moose)
Note pp_leavegiven and pp_leavewhen in HACKING
Modified: trunk/HACKING
==============================================================================
--- trunk/HACKING (original)
+++ trunk/HACKING Sat May 9 15:22:10 2009
@@ -375,3 +375,5 @@
Use FID_ATTRIB tag to record autoload fids being aliases to a fid so that
reports can include a list of autoloaded subs.
+
+Check if pp_leavegiven and pp_leavewhen need handling in init_profiler().
Modified: trunk/lib/Devel/NYTProf/SubInfo.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/SubInfo.pm (original)
+++ trunk/lib/Devel/NYTProf/SubInfo.pm Sat May 9 15:22:10 2009
@@ -73,6 +73,24 @@
return bless [ @$self ] => ref $self;
}
+sub _min {
+ my ($a, $b) = @_;
+ $a = $b if not defined $a;
+ $b = $a if not defined $b;
+ # either both are defined or both are undefined here
+ return undef unless defined $a;
+ return min($a, $b);
+}
+
+sub _max {
+ my ($a, $b) = @_;
+ $a = $b if not defined $a;
+ $b = $a if not defined $b;
+ # either both are defined or both are undefined here
+ return undef unless defined $a;
+ return max($a, $b);
+}
+
# merge details of another sub into this one
# there are very few cases where this is sane thing to do
# it's meant for merging things like anon-subs in evals
@@ -83,10 +101,9 @@
# see also "case NYTP_TAG_SUB_CALLERS:" in
load_profile_data_from_stream()
- $self->[NYTP_SIi_FIRST_LINE] = min($self->[NYTP_SIi_FIRST_LINE],
$new->[NYTP_SIi_FIRST_LINE])
- if defined $new->[NYTP_SIi_FIRST_LINE];
- $self->[NYTP_SIi_LAST_LINE] = max($self->[NYTP_SIi_LAST_LINE],
$new->[NYTP_SIi_LAST_LINE])
- if defined $new->[NYTP_SIi_LAST_LINE];
+ $self->[NYTP_SIi_FIRST_LINE] = _min($self->[NYTP_SIi_FIRST_LINE],
$new->[NYTP_SIi_FIRST_LINE]);
+ $self->[NYTP_SIi_LAST_LINE] = _max($self->[NYTP_SIi_LAST_LINE],
$new->[NYTP_SIi_LAST_LINE]);
+
$self->[NYTP_SIi_CALL_COUNT] += $new->[NYTP_SIi_CALL_COUNT];
$self->[NYTP_SIi_INCL_RTIME] += $new->[NYTP_SIi_INCL_RTIME];
$self->[NYTP_SIi_EXCL_RTIME] += $new->[NYTP_SIi_EXCL_RTIME];
--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]
-~----------~----~----~----~------~----~------~--~---