summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-03-23 13:16:53 +0000
committerNicholas Clark <nick@ccl4.org>2006-03-23 13:16:53 +0000
commit57d7fbf1cb64ed175ce62552c70317e98a87db33 (patch)
tree4e1dba47131dc11086f0503012e32a1613d296b0
parentab455f6077c4f8e6e59a143e82bbdc3535ce31e5 (diff)
downloadperl-57d7fbf1cb64ed175ce62552c70317e98a87db33.tar.gz
Complete the other 2 arms of the cache update code.
p4raw-id: //depot/perl@27583
-rw-r--r--sv.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index bc0cde887c..5360a3002c 100644
--- a/sv.c
+++ b/sv.c
@@ -5623,6 +5623,48 @@ S_utf8_mg_pos_cache_update(pTHX_ SV *sv, MAGIC **mgp, STRLEN byte, STRLEN utf8,
}
}
}
+ else if (byte > cache[3]) {
+ /* New position is between the existing pair of pairs. */
+ const float keep_earlier
+ = THREEWAY_SQUARE(0, cache[3], byte, blen);
+ const float keep_later
+ = THREEWAY_SQUARE(0, byte, cache[1], blen);
+
+ if (keep_later < keep_earlier) {
+ if (keep_later < existing) {
+ cache[2] = utf8;
+ cache[3] = byte;
+ }
+ }
+ else {
+ if (keep_earlier < existing) {
+ cache[0] = utf8;
+ cache[1] = byte;
+ }
+ }
+ }
+ else {
+ /* New position is before the existing pair of pairs. */
+ const float keep_earlier
+ = THREEWAY_SQUARE(0, byte, cache[3], blen);
+ const float keep_later
+ = THREEWAY_SQUARE(0, byte, cache[1], blen);
+
+ if (keep_later < keep_earlier) {
+ if (keep_later < existing) {
+ cache[2] = utf8;
+ cache[3] = byte;
+ }
+ }
+ else {
+ if (keep_earlier < existing) {
+ cache[0] = cache[2];
+ cache[1] = cache[3];
+ cache[2] = utf8;
+ cache[3] = byte;
+ }
+ }
+ }
}
ASSERT_UTF8_CACHE(cache);
}