Revision: 1035
Author: [email protected]
Date: Thu Jan 21 06:56:43 2010
Log: In append_linenum_to_begin(), avoid using *printf functions to build
the sub's
full name. The old code was specially sub-optimal because it used %s to
interpolate the subroutine's name, for a code path where the subroutine's
name
was always "BEGIN".
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1035
Modified:
/trunk/NYTProf.xs
=======================================
--- /trunk/NYTProf.xs Thu Jan 21 06:21:26 2010
+++ /trunk/NYTProf.xs Thu Jan 21 06:56:43 2010
@@ -1743,6 +1743,8 @@
SV *fullnamesv;
SV *DBsv;
char *subname = SvPVX(subr_entry->called_subnam_sv);
+ STRLEN pkg_len;
+ STRLEN total_len;
/* If sub is a BEGIN then append the line number to our name
* so multiple BEGINs (either explicit or implicit, e.g., "use")
@@ -1752,8 +1754,14 @@
return;
/* get, and delete, the entry for this sub in the PL_DBsub hash */
- fullnamesv = newSVpvf("%s::%s", subr_entry->called_subpkg_pv, subname);
- DBsv = hv_delete(GvHV(PL_DBsub), SvPV_nolen(fullnamesv),
SvCUR(fullnamesv), 1);
+ pkg_len = strlen(subr_entry->called_subpkg_pv);
+ total_len = pkg_len + 2 /* :: */ + 5; /* BEGIN */
+ fullnamesv = newSV(total_len + 1); /* +1 for '\0' */
+ memcpy(SvPVX(fullnamesv), subr_entry->called_subpkg_pv, pkg_len);
+ memcpy(SvPVX(fullnamesv) + pkg_len, "::BEGIN", 7 + 1); /* + 1 for '\0'
*/
+ SvCUR_set(fullnamesv, total_len);
+ SvPOK_on(fullnamesv);
+ DBsv = hv_delete(GvHV(PL_DBsub), SvPVX(fullnamesv), total_len, 1);
if (DBsv && parse_DBsub_value(aTHX_ DBsv, NULL, &line, NULL)) {
SvREFCNT_inc(DBsv); /* was made mortal by hv_delete */
--
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]