diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2021-12-03 00:10:51 +0000 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2021-12-04 11:49:42 +0000 |
commit | f7f919a02477385250997b98fe25f99657653150 (patch) | |
tree | e82e9cd32275eed214553785ba0c77d2a13e501b /pp_sys.c | |
parent | 6ac93b496cce8882a9d5494bfedb84f4da7e0aee (diff) | |
download | perl-f7f919a02477385250997b98fe25f99657653150.tar.gz |
Misc microoptimizations when dealing with new SVs
In a few places, SVs can be created more efficiently or new SVs
can be assigned to more efficiently. Small changes included:
* Use sv_setpvn_fresh instead of sv_setpvn
* Use sv_mortalcopy_flags instead of sv_newmortal + sv_setsv_flags
* newSVsv_flags instead of newSV + sv_setsv_flags
* sv_newmortal instead of sv_2mortal(newSV(0))
* Remove a SvGROW(sv, 257) following a newSV(257)
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -938,7 +938,7 @@ PP(pp_tie) /* If the glob doesn't name an existing package, using * SVfARG(*MARK) would yield "*Foo::Bar" or *main::Foo. So * generate the name for the error message explicitly. */ - SV *stashname = sv_2mortal(newSV(0)); + SV *stashname = sv_newmortal(); gv_fullname4(stashname, (GV *) *MARK, NULL, FALSE); DIE(aTHX_ "Can't locate object method \"%s\" via package \"%" SVf "\"", methname, SVfARG(stashname)); @@ -2697,7 +2697,8 @@ PP(pp_ssockopt) goto nuts; switch (optype) { case OP_GSOCKOPT: - SvGROW(sv, 257); + /* Note: there used to be an explicit SvGROW(sv,257) here, but + * this is redundant given the sv initialization ternary above */ (void)SvPOK_only(sv); SvCUR_set(sv,256); *SvEND(sv) ='\0'; @@ -5063,7 +5064,8 @@ PP(pp_ghostent) if (hent) { if (which == OP_GHBYNAME) { if (hent->h_addr) - sv_setpvn(sv, hent->h_addr, hent->h_length); + sv_upgrade(sv, SVt_PV); + sv_setpvn_fresh(sv, hent->h_addr, hent->h_length); } else sv_setpv(sv, (char*)hent->h_name); |