diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2023-02-10 13:31:14 +0000 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2023-02-10 15:38:26 -0700 |
commit | 8d83c9f712bbdad0e46a7ea27be5959e9a3e4116 (patch) | |
tree | 7b124bc459662d2587456d8c34f3a90b242d3273 /toke.c | |
parent | 94a21c89d725dee58126a57a36a33a72e3dd54fd (diff) | |
download | perl-8d83c9f712bbdad0e46a7ea27be5959e9a3e4116.tar.gz |
toke.c - use SvREFCNT_dec() rather than calling sv_free()
sv_free() is a function call just to then do SvREFCNT_dec() anyway.
SvREFCNT_dec is a macro that just calls the simple inline function
Perl_SvREFCNT_dec(). In places where the SV being operated on has
been newly creted, we can use ASSUME() statements to help the
compiler to eliminate some unnecessary branches in this function.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -4819,7 +4819,7 @@ Perl_filter_del(pTHX_ filter_t funcp) /* if filter is on top of stack (usual case) just pop it off */ datasv = FILTER_DATA(AvFILLp(PL_rsfp_filters)); if (IoANY(datasv) == FPTR2DPTR(void *, funcp)) { - sv_free(av_pop(PL_rsfp_filters)); + SvREFCNT_dec(av_pop(PL_rsfp_filters)); return; } @@ -6016,7 +6016,8 @@ yyl_colon(pTHX_ char *s) if (!d) { if (attrs) op_free(attrs); - sv_free(sv); + ASSUME(sv && SvREFCNT(sv) == 1); + SvREFCNT_dec(sv); Perl_croak(aTHX_ "Unterminated attribute parameter in attribute list"); } COPLINE_SET_FROM_MULTI_END; @@ -8937,7 +8938,8 @@ yyl_keylookup(pTHX_ char *s, GV *gv) SVt_PVCV); c.off = 0; if (!c.gv) { - sv_free(c.sv); + ASSUME(c.sv && SvREFCNT(c.sv) == 1); + SvREFCNT_dec(c.sv); c.sv = NULL; return yyl_just_a_word(aTHX_ s, len, 0, c); } @@ -9080,7 +9082,7 @@ yyl_try(pTHX_ char *s) ++svp; sv_catpvs(PL_linestr, ";"); } - sv_free(MUTABLE_SV(PL_preambleav)); + SvREFCNT_dec(MUTABLE_SV(PL_preambleav)); PL_preambleav = NULL; } if (PL_minus_E) @@ -11792,7 +11794,8 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int COPLINE_INC_WITH_HERELINES; PL_bufptr = PL_bufend; if (!lex_next_chunk(0)) { - sv_free(sv); + ASSUME(sv); + SvREFCNT_dec(sv); CopLINE_set(PL_curcop, (line_t)PL_multi_start); return NULL; } |