Fixes #353862 (Improve performance of QuotedStringTokenizer.quote()). Corrected various implementation mistakes (thanks test suite).

This commit is contained in:
Simone Bordet 2011-08-04 14:44:21 +02:00
parent 01cbaf528b
commit 449db20d7d
1 changed files with 4 additions and 4 deletions

View File

@ -316,10 +316,10 @@ public class QuotedStringTokenizer
}
private static final char[] escapes = new char[31];
private static final char[] escapes = new char[32];
static
{
Arrays.fill(escapes, (char)-1);
Arrays.fill(escapes, (char)0xFFFF);
escapes['\b'] = 'b';
escapes['\t'] = 't';
escapes['\n'] = 'n';
@ -350,10 +350,10 @@ public class QuotedStringTokenizer
else
{
char escape = escapes[c];
if (escape == -1)
if (escape == 0xFFFF)
{
// Unicode escape
buffer.append('\\').append('0').append('0');
buffer.append('\\').append('u').append('0').append('0');
if (c < 0x10)
buffer.append('0');
buffer.append(Integer.toString(c, 16));