only do \C hackery if \C is seen
Yves Orton [Fri, 20 Oct 2006 12:38:13 +0000 (14:38 +0200)]
Subject: Re: utf8 regexp performance problem
Message-ID: <9b18b3110610200338k5df1d3afpf829fbc0f3663a75@mail.gmail.com>

p4raw-id: //depot/perl@29063

mg.c

diff --git a/mg.c b/mg.c
index 3ab49c0..7c19c7e 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -861,8 +861,13 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
                    TAINT_NOT;
                    sv_setpvn(sv, s, i);
                    PL_tainted = oldtainted;
-                   if (RX_MATCH_UTF8(rx) && (!i || is_utf8_string((U8*)s, i)))
+                   if ( (rx->reganch & ROPT_CANY_SEEN)
+                       ? (RX_MATCH_UTF8(rx)
+                                   && (!i || is_utf8_string((U8*)s, i)))
+                       : (RX_MATCH_UTF8(rx)) )
+                   {
                        SvUTF8_on(sv);
+                   }
                    else
                        SvUTF8_off(sv);
                    if (PL_tainting) {