summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2021-11-23 23:35:58 +0000
committerTony Cook <tony@develop-help.com>2021-11-29 10:11:45 +1100
commit2a98b8cbbc6f75b5aaefb10acc4da4427359fcea (patch)
tree8a80adaddccc882df24d9656979b67aa8daeba95
parentc80a8618143e98aed6d9e5bbaee16d0308e211d0 (diff)
downloadperl-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.c6
-rw-r--r--pp_sys.c2
-rw-r--r--regcomp.c7
-rw-r--r--toke.c2
4 files changed, 8 insertions, 9 deletions
diff --git a/op.c b/op.c
index 3c5079ab4d..abf1a81031 100644
--- a/op.c
+++ b/op.c
@@ -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. */
diff --git a/pp_sys.c b/pp_sys.c
index a23581b016..278f38d58d 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -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));
diff --git a/regcomp.c b/regcomp.c
index b2a54c4ec3..9fe867b2fa 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -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
diff --git a/toke.c b/toke.c
index aa27c44950..49d66e5c14 100644
--- a/toke.c
+++ b/toke.c
@@ -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"