diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2014-12-26 09:15:23 -0500 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-12-26 17:33:00 -0800 |
commit | b4f8d1496ced441d5dcfda7a0f178eff0a71fe4b (patch) | |
tree | 3845338ae15b2e5d086dee0a9008092f59cbb767 /perl.h | |
parent | 470eba0e5823387f90604f7cf9fc354694a0a9ba (diff) | |
download | perl-b4f8d1496ced441d5dcfda7a0f178eff0a71fe4b.tar.gz |
optimize CLEAR_ERRSV
-gv_add_by_type is special only for non-GVs, and add AV to GV, otherwise
it is just assigning to GP slot (in this case through GvSV), which
CLEAR_ERRSV already did in another branch, so inline the gv_add_by_type
-dont compute GvSV multiple times, GvSV contains 2 derefs, after this patch
it will contains just 1 deref ("*svp") without an offset (deref without
offset is smaller in x86 machine code than deref with offset)
-SvREFCNT_dec_NN for efficiency
-move SvPOK_only closer to SvMAGICAL, this ensures SvFLAGS is read and
written only once, not 2 reads and 1 write, this is specifically for
RISC-ish cpus
-the goto clresv_newemptypv is because VC optimizer in -O1 didn't combine
the branches
perl521.dll VC 2003 before .text section size in machine code bytes
0xc8a63, after 0xc88e3
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1269,19 +1269,22 @@ EXTERN_C char *crypt(const char *, const char *); #define ERRSV GvSVn(PL_errgv) +/* contains inlined gv_add_by_type */ #define CLEAR_ERRSV() STMT_START { \ - if (!GvSV(PL_errgv)) { \ - sv_setpvs(GvSV(gv_add_by_type(PL_errgv, SVt_PV)), ""); \ - } else if (SvREADONLY(GvSV(PL_errgv))) { \ - SvREFCNT_dec(GvSV(PL_errgv)); \ - GvSV(PL_errgv) = newSVpvs(""); \ + SV ** const svp = &GvSV(PL_errgv); \ + if (!*svp) { \ + goto clresv_newemptypv; \ + } else if (SvREADONLY(*svp)) { \ + SvREFCNT_dec_NN(*svp); \ + clresv_newemptypv: \ + *svp = newSVpvs(""); \ } else { \ - SV *const errsv = GvSV(PL_errgv); \ + SV *const errsv = *svp; \ sv_setpvs(errsv, ""); \ + SvPOK_only(errsv); \ if (SvMAGICAL(errsv)) { \ mg_free(errsv); \ } \ - SvPOK_only(errsv); \ } \ } STMT_END |