diff options
| author | Daniel Veillard <veillard@src.gnome.org> | 2002-05-31 09:47:30 +0000 |
|---|---|---|
| committer | Daniel Veillard <veillard@src.gnome.org> | 2002-05-31 09:47:30 +0000 |
| commit | e72c7563663462b6c9efa879831c00da1f081bd8 (patch) | |
| tree | b7a98084d28eed3bae2eff1f0f8b8285b2a90812 /encoding.c | |
| parent | 617acc3c2ed7f536a00ec221d5f4bd9e592e3195 (diff) | |
| download | android_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.c | 43 |
1 files changed, 21 insertions, 22 deletions
@@ -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 |
