summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-07-11 16:49:29 +0100
committerNicholas Clark <nick@ccl4.org>2010-07-11 16:49:29 +0100
commit503752a16bf16b90ff6c073c4bd5d818e68a2e2a (patch)
treea7f1750648af9b068d84084f5b5024fc2ce76871 /sv.c
parent65cccc5e92d46159b5887e72094aab44ee260ea3 (diff)
downloadperl-503752a16bf16b90ff6c073c4bd5d818e68a2e2a.tar.gz
In S_sv_pos_u2b_midway, inline the call to S_sv_pos_u2b_forwards.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index c38a318f74..45a98946ef 100644
--- a/sv.c
+++ b/sv.c
@@ -6110,7 +6110,7 @@ S_sv_pos_u2b_forwards(const U8 *const start, const U8 *const send,
the passed in UTF-8 offset. */
static STRLEN
S_sv_pos_u2b_midway(const U8 *const start, const U8 *send,
- const STRLEN uoffset, const STRLEN uend)
+ STRLEN uoffset, const STRLEN uend)
{
STRLEN backw = uend - uoffset;
@@ -6120,7 +6120,14 @@ S_sv_pos_u2b_midway(const U8 *const start, const U8 *send,
/* The assumption is that going forwards is twice the speed of going
forward (that's where the 2 * backw comes from).
(The real figure of course depends on the UTF-8 data.) */
- return sv_pos_u2b_forwards(start, send, uoffset);
+ const U8 *s = start;
+
+ while (s < send && uoffset--)
+ s += UTF8SKIP(s);
+ assert (s <= send);
+ if (s > send)
+ s = send;
+ return s - start;
}
while (backw--) {