diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2021-11-23 23:35:58 +0000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2021-11-29 10:11:45 +1100 |
commit | 2a98b8cbbc6f75b5aaefb10acc4da4427359fcea (patch) | |
tree | 8a80adaddccc882df24d9656979b67aa8daeba95 | |
parent | c80a8618143e98aed6d9e5bbaee16d0308e211d0 (diff) | |
download | perl-2a98b8cbbc6f75b5aaefb10acc4da4427359fcea.tar.gz |
newSVpvn_flags().. is more efficient than sv_2mortal(newSVpvn(..))
The same holds for newSVpvs* wrappers around newSVpvn* functions.
-rw-r--r-- | op.c | 6 | ||||
-rw-r--r-- | pp_sys.c | 2 | ||||
-rw-r--r-- | regcomp.c | 7 | ||||
-rw-r--r-- | toke.c | 2 |
4 files changed, 8 insertions, 9 deletions
@@ -10934,9 +10934,9 @@ S_already_defined(pTHX_ CV *const cv, OP * const block, OP * const o, const line_t oldline = CopLINE(PL_curcop); SV *namesv = o ? cSVOPo->op_sv - : sv_2mortal(newSVpvn_utf8( - PadnamePV(name)+1,PadnameLEN(name)-1, PadnameUTF8(name) - )); + : newSVpvn_flags( PadnamePV(name)+1,PadnameLEN(name)-1, + (PadnameUTF8(name)) ? SVf_UTF8|SVs_TEMP : SVs_TEMP + ); if (PL_parser && PL_parser->copline != NOLINE) /* This ensures that warnings are reported at the first line of a redefinition, not the last. */ @@ -946,7 +946,7 @@ PP(pp_tie) else { SV *stashname = !SvPOK(*MARK) ? &PL_sv_no : SvCUR(*MARK) ? *MARK - : sv_2mortal(newSVpvs("main")); + : newSVpvs_flags("main", SVs_TEMP); DIE(aTHX_ "Can't locate object method \"%s\" via package \"%" SVf "\"" " (perhaps you forgot to load \"%" SVf "\"?)", methname, SVfARG(stashname), SVfARG(stashname)); @@ -18537,7 +18537,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth, if (! RExC_in_multi_char_class) { STRLEN cp_count = utf8_length(foldbuf, foldbuf + foldlen); - SV* multi_fold = sv_2mortal(newSVpvs("")); + SV* multi_fold = newSVpvs_flags("", SVs_TEMP); Perl_sv_catpvf(aTHX_ multi_fold, "\\x{%" UVXf "}", value); @@ -23410,7 +23410,7 @@ S_compile_wildcard(pTHX_ const char * subpattern, const STRLEN len, U32 flags = PMf_MULTILINE|PMf_WILDCARD; U32 rx_flags; - SV * subpattern_sv = sv_2mortal(newSVpvn(subpattern, len)); + SV * subpattern_sv = newSVpvn_flags(subpattern, len, SVs_TEMP); REGEXP * subpattern_re; DECLARE_AND_GET_RE_DEBUG_FLAGS; @@ -24650,11 +24650,10 @@ S_parse_uniprop_string(pTHX_ * We start by constructing the hash key name, consisting of the * fully qualified subroutine name, preceded by the /i status, so * that there is a key for /i and a different key for non-/i */ - key = newSVpvn(((to_fold) ? "1" : "0"), 1); + key = newSVpvn_flags(((to_fold) ? "1" : "0"), 1, SVs_TEMP); fq_name = S_get_fq_name(aTHX_ name, name_len, is_utf8, non_pkg_begin != 0); sv_catsv(key, fq_name); - sv_2mortal(key); /* We only call the sub once throughout the life of the program * (with the /i, non-/i exception noted above). That means the @@ -725,7 +725,7 @@ S_missingterm(pTHX_ char *s, STRLEN len) s = tmpbuf; } q = memchr(s, '"', len) ? '\'' : '"'; - sv = sv_2mortal(newSVpvn(s, len)); + sv = newSVpvn_flags(s, len, SVs_TEMP); if (uni) SvUTF8_on(sv); Perl_croak(aTHX_ "Can't find string terminator %c%" SVf "%c" |