aboutsummaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-05-31 09:47:30 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-05-31 09:47:30 +0000
commite72c7563663462b6c9efa879831c00da1f081bd8 (patch)
treeb7a98084d28eed3bae2eff1f0f8b8285b2a90812 /encoding.c
parent617acc3c2ed7f536a00ec221d5f4bd9e592e3195 (diff)
downloadandroid_external_libxml2-e72c7563663462b6c9efa879831c00da1f081bd8.tar.gz
android_external_libxml2-e72c7563663462b6c9efa879831c00da1f081bd8.tar.bz2
android_external_libxml2-e72c7563663462b6c9efa879831c00da1f081bd8.zip
another peroformance patch from Peter Jacobi, that time on parsing
* parser.c: another peroformance patch from Peter Jacobi, that time on parsing attribute values. Daniel
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/encoding.c b/encoding.c
index 8e2397a2..08dda58e 100644
--- a/encoding.c
+++ b/encoding.c
@@ -560,39 +560,38 @@ isolat1ToUTF8(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen) {
unsigned char* outstart = out;
const unsigned char* base = in;
- const unsigned char* processed = in;
unsigned char* outend = out + *outlen;
const unsigned char* inend;
- unsigned int c;
+ const unsigned char* instop;
+ xmlChar c = *in;
inend = in + (*inlen);
- while (in < inend) {
- c = *in++;
-
- if (out >= outend)
- break;
-
- if (c < 0x80) {
- *out++ = c;
- processed++;
- continue;
- } else {
- /*
- * make sure there is 2 chars left in advance
- */
- if (out + 1 >= outend) {
- break;
- }
+ instop = inend;
+
+ while (in < inend && out < outend - 1) {
+ if (c >= 0x80) {
*out++= ((c >> 6) & 0x1F) | 0xC0;
*out++= (c & 0x3F) | 0x80;
- processed++;
- }
+ ++in;
+ c = *in;
+ }
+ if (instop - in > outend - out) instop = in + (outend - out);
+ while (c < 0x80 && in < instop) {
+ *out++ = c;
+ ++in;
+ c = *in;
+ }
+ }
+ if (in < inend && out < outend && c < 0x80) {
+ *out++ = c;
+ ++in;
}
*outlen = out - outstart;
- *inlen = processed - base;
+ *inlen = in - base;
return(0);
}
+
/**
* UTF8Toisolat1:
* @out: a pointer to an array of bytes to store the result