From: Nick Ing-Simmons Date: Tue, 12 Dec 2000 19:42:13 +0000 (+0000) Subject: Integrate/merge mainline with further efficiency tweak to sv.c's utf8 stuff. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=511c2ff04fc070a9b9389f53ec595d85ce870c80;p=p5sagit%2Fp5-mst-13.2.git Integrate/merge mainline with further efficiency tweak to sv.c's utf8 stuff. p4raw-id: //depot/perlio@8093 --- 511c2ff04fc070a9b9389f53ec595d85ce870c80 diff --cc sv.c index e29d1b4,e29d1b4..7c9c4db --- a/sv.c +++ b/sv.c @@@ -2390,36 -2390,36 +2390,37 @@@ Convert the PV of an SV to its UTF8-enc void Perl_sv_utf8_upgrade(pTHX_ register SV *sv) { -- char *s, *t; -- int hibit = FALSE; ++ char *s, *t, *e; ++ int hibit = 0; if (!sv || !SvPOK(sv) || SvUTF8(sv)) return; /* This function could be much more efficient if we had a FLAG in SVs * to signal if there are any hibit chars in the PV. ++ * Given that there isn't make loop fast as possible */ -- for (s = t = SvPVX(sv); t < SvEND(sv) && !hibit; t++) { -- if (*t & 0x80) { -- hibit = TRUE; ++ s = SvPVX(sv); ++ e = SvEND(sv); ++ t = s; ++ while (t < e) { ++ if ((hibit = *t++ & 0x80)) break; -- } } if (hibit) { STRLEN len; if (SvREADONLY(sv) && SvFAKE(sv)) { -- Perl_warn(aTHX_ "%d s=%p t=%p e=%p",(int)hibit,s,t,SvEND(sv)); -- sv_dump(sv); sv_force_normal(sv); s = SvPVX(sv); } len = SvCUR(sv) + 1; /* Plus the \0 */ SvPVX(sv) = (char*)bytes_to_utf8((U8*)s, &len); SvCUR(sv) = len - 1; ++ if (SvLEN(sv) != 0) ++ Safefree(s); /* No longer using what was there before. */ SvLEN(sv) = len; /* No longer know the real size. */ SvUTF8_on(sv); -- Safefree(s); /* No longer using what was there before. */ } } @@@ -2482,6 -2482,6 +2483,7 @@@ Perl_sv_utf8_decode(pTHX_ register SV * { if (SvPOK(sv)) { char *c; ++ char *e; bool has_utf = FALSE; if (!sv_utf8_downgrade(sv, TRUE)) return FALSE; @@@ -2492,8 -2492,8 +2494,8 @@@ c = SvPVX(sv); if (!is_utf8_string((U8*)c, SvCUR(sv)+1)) return FALSE; -- -- while (c < SvEND(sv)) { ++ e = SvEND(sv); ++ while (c < e) { if (*c++ & 0x80) { SvUTF8_on(sv); break;