From: Jarkko Hietaniemi Date: Thu, 27 Jun 2002 20:53:44 +0000 (+0000) Subject: Inlining to avoid costly UTF-8 calls. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cc07378bd850d5f9faaa12b44277d091729e30f0;p=p5sagit%2Fp5-mst-13.2.git Inlining to avoid costly UTF-8 calls. p4raw-id: //depot/perl@17372 --- diff --git a/regexec.c b/regexec.c index f196cb7..389fa1d 100644 --- a/regexec.c +++ b/regexec.c @@ -4328,12 +4328,13 @@ S_reginclass(pTHX_ register regnode *n, register U8* p, STRLEN* lenp, register b { char flags = ANYOF_FLAGS(n); bool match = FALSE; - UV c; + UV c = *p; STRLEN len = 0; STRLEN plen; - c = do_utf8 ? utf8n_to_uvchr(p, UTF8_MAXLEN, &len, - ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY) : *p; + if (do_utf8 && !UTF8_IS_INVARIANT(c)) + c = utf8n_to_uvchr(p, UTF8_MAXLEN, &len, + ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY); plen = lenp ? *lenp : UNISKIP(NATIVE_TO_UNI(c)); if (do_utf8 || (flags & ANYOF_UNICODE)) { diff --git a/sv.c b/sv.c index 1c1932a..fa629ae 100644 --- a/sv.c +++ b/sv.c @@ -5313,9 +5313,11 @@ Perl_sv_pos_b2u(pTHX_ register SV *sv, I32* offsetp) send = s + *offsetp; len = 0; while (s < send) { - STRLEN n; - /* Call utf8n_to_uvchr() to validate the sequence */ - utf8n_to_uvchr(s, UTF8SKIP(s), &n, 0); + STRLEN n = 1; + /* Call utf8n_to_uvchr() to validate the sequence + * (unless a simple non-UTF character) */ + if (!UTF8_IS_INVARIANT(*s)) + utf8n_to_uvchr(s, UTF8SKIP(s), &n, 0); if (n > 0) { s += n; len++;