summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-08-28 16:14:21 +0200
committerNicholas Clark <nick@ccl4.org>2013-08-29 18:22:43 +0200
commit089b5c60c035d158afd7e1bbfdd8d9229beea884 (patch)
tree7472f23ebc4b47485d60c87448a84828ab576a51 /mg.c
parent3f40aba3cc2139eb7b147b8db25c9d3ed7e7adb0 (diff)
downloadperl-089b5c60c035d158afd7e1bbfdd8d9229beea884.tar.gz
In Perl_magic_setdbline, replace the use of atoi() with sv_2iv().
The value on which atoi() is called is actually always the buffer of an SV. Hence we can use sv_2iv() instead.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/mg.c b/mg.c
index 543af8152a..f70a5e9e58 100644
--- a/mg.c
+++ b/mg.c
@@ -1985,13 +1985,20 @@ int
Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg)
{
dVAR;
- GV * const gv = PL_DBline;
- const I32 i = SvTRUE(sv);
- SV ** const svp = av_fetch(GvAV(gv),
- atoi(MgPV_nolen_const(mg)), FALSE);
+ SV **svp;
PERL_ARGS_ASSERT_MAGIC_SETDBLINE;
+ /* The magic ptr/len for the debugger's hash should always be an SV. */
+ if (UNLIKELY(mg->mg_len != HEf_SVKEY)) {
+ Perl_croak(aTHX_ "panic: magic_setdbline len=%"IVdf", ptr='%s'",
+ mg->mg_len, mg->mg_ptr);
+ }
+
+ /* Use sv_2iv instead of SvIV() as the former generates smaller code, and
+ setting/clearing debugger breakpoints is not a hot path. */
+ svp = av_fetch(GvAV(PL_DBline), sv_2iv(MUTABLE_SV((mg)->mg_ptr)), FALSE);
+
if (svp && SvIOKp(*svp)) {
OP * const o = INT2PTR(OP*,SvIVX(*svp));
if (o) {
@@ -1999,7 +2006,7 @@ Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg)
Slab_to_rw(OpSLAB(o));
#endif
/* set or clear breakpoint in the relevant control op */
- if (i)
+ if (SvTRUE(sv))
o->op_flags |= OPf_SPECIAL;
else
o->op_flags &= ~OPf_SPECIAL;