diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-03-17 13:38:34 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-03-17 13:38:34 +0000 |
commit | d83f0a8247ea7458731c8479d8cbf3ee1fa81243 (patch) | |
tree | c7b22a3a0257894aa9ec9c70af39e396f7212d7b /mg.c | |
parent | b4a415570dc258ddaff4bbab5c0f83c1af645b29 (diff) | |
download | perl-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 'mg.c')
-rw-r--r-- | mg.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1803,8 +1803,12 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) if (!mg) { if (!SvOK(sv)) return 0; - sv_magic(lsv, NULL, PERL_MAGIC_regex_global, NULL, 0); - mg = mg_find(lsv, PERL_MAGIC_regex_global); +#ifdef PERL_OLD_COPY_ON_WRITE + if (SvIsCOW(lsv)) + sv_force_normal_flags(lsv, 0); +#endif + mg = sv_magicext(lsv, NULL, PERL_MAGIC_regex_global, &PL_vtbl_mglob, + NULL, 0); } else if (!SvOK(sv)) { mg->mg_len = -1; |