diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-03 17:15:53 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-03 17:15:53 +0000 |
commit | 59cd0e26eb6c10499b25d783562357dd68cc16f2 (patch) | |
tree | 68198e7261586c25728270515fa4f9f3acd7735c /pp.c | |
parent | d16d613cbabd929abf5d13edb895c38c5a99bc29 (diff) | |
download | perl-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 'pp.c')
-rw-r--r-- | pp.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -449,7 +449,7 @@ PP(pp_prototype) if (defgv && str[n - 1] == '$') str[n - 1] = '_'; str[n++] = '\0'; - ret = sv_2mortal(newSVpvn(str, n - 1)); + ret = newSVpvn_flags(str, n - 1, SVs_TEMP); } else if (code) /* Non-Overridable */ goto set; @@ -461,7 +461,7 @@ PP(pp_prototype) } cv = sv_2cv(TOPs, &stash, &gv, 0); if (cv && SvPOK(cv)) - ret = sv_2mortal(newSVpvn(SvPVX_const(cv), SvCUR(cv))); + ret = newSVpvn_flags(SvPVX_const(cv), SvCUR(cv), SVs_TEMP); set: SETs(ret); RETURN; @@ -3312,7 +3312,8 @@ PP(pp_index) Otherwise I need to avoid calls to sv_pos_u2b(), which (dangerously) will trigger magic and overloading again, as will fbm_instr() */ - big = sv_2mortal(newSVpvn_utf8(big_p, biglen, big_utf8)); + big = newSVpvn_flags(big_p, biglen, + SVs_TEMP | (big_utf8 ? SVf_UTF8 : 0)); big_p = SvPVX(big); } if (SvGAMAGIC(little) || (is_index && !SvOK(little))) { @@ -3324,7 +3325,8 @@ PP(pp_index) This is all getting to messy. The API isn't quite clean enough, because data access has side effects. */ - little = sv_2mortal(newSVpvn_utf8(little_p, llen, little_utf8)); + little = newSVpvn_flags(little_p, llen, + SVs_TEMP | (little_utf8 ? SVf_UTF8 : 0)); little_p = SvPVX(little); } |