From: Nicholas Clark Date: Mon, 20 Mar 2006 19:30:48 +0000 (+0000) Subject: Extend change 27558 - if we know the character offset of the end, but X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffca234a07dfeae45b7c9ca966164446c5bc3d4b;p=p5sagit%2Fp5-mst-13.2.git Extend change 27558 - if we know the character offset of the end, but don't have a cache for intermediate offsets, we can still use the end offset. p4raw-id: //depot/perl@27559 --- diff --git a/sv.c b/sv.c index 2641da0..e8b46ca 100644 --- a/sv.c +++ b/sv.c @@ -5686,9 +5686,9 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp) send = s + byte; - if (SvMAGICAL(sv) && !SvREADONLY(sv) && PL_utf8cache) { - mg = mg_find(sv, PERL_MAGIC_utf8); - if (mg && mg->mg_ptr) { + if (SvMAGICAL(sv) && !SvREADONLY(sv) && PL_utf8cache + && (mg = mg_find(sv, PERL_MAGIC_utf8))) { + if (mg->mg_ptr) { STRLEN *cache = (STRLEN *) mg->mg_ptr; if (cache[1] == byte) { /* An exact match. */ @@ -5727,6 +5727,8 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp) (UV) len, (UV) reallen, sv); } } + } else if (mg->mg_len != -1) { + len = S_sv_pos_b2u_midway(aTHX_ s, send, s + len, mg->mg_len); } else { len = S_sv_pos_b2u_forwards(aTHX_ s, send); }