summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-03 17:15:53 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-03 17:15:53 +0000
commit59cd0e26eb6c10499b25d783562357dd68cc16f2 (patch)
tree68198e7261586c25728270515fa4f9f3acd7735c /hv.c
parentd16d613cbabd929abf5d13edb895c38c5a99bc29 (diff)
downloadperl-59cd0e26eb6c10499b25d783562357dd68cc16f2.tar.gz
Extend newSVpvn_flags() to also call sv_2mortal() if SVs_TEMP is set in
the flags. Move its implementation just ahead of sv_2mortal()'s for CPU cache locality. Refactor all code that can be to use this. p4raw-id: //depot/perl@32818
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hv.c b/hv.c
index 63e10497ce..f0d8033329 100644
--- a/hv.c
+++ b/hv.c
@@ -350,8 +350,9 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
SV* obj = mg->mg_obj;
if (!keysv) {
- keysv = sv_2mortal(newSVpvn_utf8(key, klen,
- flags & HVhek_UTF8));
+ keysv = newSVpvn_flags(key, klen, SVs_TEMP |
+ ((flags & HVhek_UTF8)
+ ? SVf_UTF8 : 0));
}
mg->mg_obj = keysv; /* pass key */
@@ -913,7 +914,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
#ifdef ENV_IS_CASELESS
else if (mg_find((SV*)hv, PERL_MAGIC_env)) {
/* XXX This code isn't UTF8 clean. */
- keysv = sv_2mortal(newSVpvn(key,klen));
+ keysv = newSVpvn_flags(key, klen, SVs_TEMP);
if (k_flags & HVhek_FREEKEY) {
Safefree(key);
}