Change 27552 by [EMAIL PROTECTED] on 2006/03/20 12:13:46
The two loops in Perl_utf8_distance can be merged.
Affected files ...
... //depot/perl/utf8.c#278 edit
Differences ...
==== //depot/perl/utf8.c#278 (text) ====
Index: perl/utf8.c
--- perl/utf8.c#277~27300~ 2006-02-24 02:41:53.000000000 -0800
+++ perl/utf8.c 2006-03-20 04:13:46.000000000 -0800
@@ -705,41 +705,37 @@
{
dVAR;
IV off = 0;
+ IV sign = 1;
/* Note: cannot use UTF8_IS_...() too eagerly here since e.g.
* the bitops (especially ~) can create illegal UTF-8.
* In other words: in Perl UTF-8 is not just for Unicode. */
if (a < b) {
- while (a < b) {
- const U8 c = UTF8SKIP(a);
- if (b - a < c)
- goto warn_and_return;
- a += c;
- off--;
- }
- }
- else {
- while (b < a) {
- const U8 c = UTF8SKIP(b);
-
- if (a - b < c) {
- warn_and_return:
- if (ckWARN_d(WARN_UTF8)) {
- if (PL_op)
- Perl_warner(aTHX_ packWARN(WARN_UTF8),
- "%s in %s", unees, OP_DESC(PL_op));
- else
- Perl_warner(aTHX_ packWARN(WARN_UTF8), unees);
- }
- return off;
+ const U8 *const temp = a;
+ a = b;
+ b = temp;
+ sign = -1;
+ }
+
+ while (b < a) {
+ const U8 c = UTF8SKIP(b);
+
+ if (a - b < c) {
+ if (ckWARN_d(WARN_UTF8)) {
+ if (PL_op)
+ Perl_warner(aTHX_ packWARN(WARN_UTF8),
+ "%s in %s", unees, OP_DESC(PL_op));
+ else
+ Perl_warner(aTHX_ packWARN(WARN_UTF8), unees);
}
- b += c;
- off++;
+ return off * sign;
}
+ b += c;
+ off++;
}
- return off;
+ return off * sign;
}
/*
End of Patch.