summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-03-17 13:38:34 +0000
committerNicholas Clark <nick@ccl4.org>2006-03-17 13:38:34 +0000
commitd83f0a8247ea7458731c8479d8cbf3ee1fa81243 (patch)
treec7b22a3a0257894aa9ec9c70af39e396f7212d7b /pp_hot.c
parentb4a415570dc258ddaff4bbab5c0f83c1af645b29 (diff)
downloadperl-d83f0a8247ea7458731c8479d8cbf3ee1fa81243.tar.gz
sv_find() returning false, followed by sv_magic() to add the magic,
followed immediately by sv_find() to find it, is somewhat wasteful. So use sv_magicext(). (All cases are also correct w.r.t. SvREADONLY()) p4raw-id: //depot/perl@27533
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/pp_hot.c b/pp_hot.c
index f28b0421c3..c34fb90fb2 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1405,8 +1405,12 @@ play_it_again:
if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG))
mg = mg_find(TARG, PERL_MAGIC_regex_global);
if (!mg) {
- sv_magic(TARG, NULL, PERL_MAGIC_regex_global, NULL, 0);
- mg = mg_find(TARG, PERL_MAGIC_regex_global);
+#ifdef PERL_OLD_COPY_ON_WRITE
+ if (SvIsCOW(TARG))
+ sv_force_normal_flags(TARG, 0);
+#endif
+ mg = sv_magicext(TARG, NULL, PERL_MAGIC_regex_global,
+ &PL_vtbl_mglob, NULL, 0);
}
if (rx->startp[0] != -1) {
mg->mg_len = rx->endp[0];
@@ -1435,8 +1439,12 @@ play_it_again:
else
mg = NULL;
if (!mg) {
- sv_magic(TARG, NULL, PERL_MAGIC_regex_global, NULL, 0);
- mg = mg_find(TARG, PERL_MAGIC_regex_global);
+#ifdef PERL_OLD_COPY_ON_WRITE
+ if (SvIsCOW(TARG))
+ sv_force_normal_flags(TARG, 0);
+#endif
+ mg = sv_magicext(TARG, NULL, PERL_MAGIC_regex_global,
+ &PL_vtbl_mglob, NULL, 0);
}
if (rx->startp[0] != -1) {
mg->mg_len = rx->endp[0];