summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-03-23 13:47:41 +0000
committerNicholas Clark <nick@ccl4.org>2006-03-23 13:47:41 +0000
commit9f985e4c436303340569d267e23865fa9c16fba7 (patch)
tree49152fc9104291f55d0c0e7f39103efed05c6162 /sv.c
parent57d7fbf1cb64ed175ce62552c70317e98a87db33 (diff)
downloadperl-9f985e4c436303340569d267e23865fa9c16fba7.tar.gz
Use both cache entries for Perl_sv_pos_b2u().
p4raw-id: //depot/perl@27584
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index 5360a3002c..62f6107c07 100644
--- a/sv.c
+++ b/sv.c
@@ -5763,9 +5763,19 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp)
+ S_sv_pos_b2u_forwards(aTHX_ s + cache[1], send);
}
}
- else { /* cache[1] > byte */
- len = S_sv_pos_b2u_midway(aTHX_ s, send, s + cache[1],
- cache[0]);
+ else if (cache[3] < byte) {
+ /* We're between the two cached pairs, so we do the calculation
+ offset by the byte/utf-8 positions for the earlier pair,
+ then add the utf-8 characters from the string start to
+ there. */
+ len = S_sv_pos_b2u_midway(aTHX_ s + cache[3], send,
+ s + cache[1], cache[0] - cache[2])
+ + cache[2];
+
+ }
+ else { /* cache[3] > byte */
+ len = S_sv_pos_b2u_midway(aTHX_ s, send, s + cache[3],
+ cache[2]);
}
ASSERT_UTF8_CACHE(cache);