Fixed a performance issue with utf8 characters.
When an utf8 char was detected in a string, jedis flushed its output buffer for each char. Now, the buffer is only flushed when it is really full.
This commit is contained in:
@@ -119,13 +119,13 @@ public final class RedisOutputStream extends FilterOutputStream {
|
|||||||
flushBuffer();
|
flushBuffer();
|
||||||
}
|
}
|
||||||
} else if (c < 0x800) {
|
} else if (c < 0x800) {
|
||||||
if(2 < buf.length - count) {
|
if(2 >= buf.length - count) {
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
}
|
}
|
||||||
buf[count++] = (byte)(0xc0 | (c >> 6));
|
buf[count++] = (byte)(0xc0 | (c >> 6));
|
||||||
buf[count++] = (byte)(0x80 | (c & 0x3f));
|
buf[count++] = (byte)(0x80 | (c & 0x3f));
|
||||||
} else if (isSurrogate(c)) {
|
} else if (isSurrogate(c)) {
|
||||||
if(4 < buf.length - count) {
|
if(4 >= buf.length - count) {
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
}
|
}
|
||||||
int uc = Character.toCodePoint(c, str.charAt(i++));
|
int uc = Character.toCodePoint(c, str.charAt(i++));
|
||||||
@@ -134,7 +134,7 @@ public final class RedisOutputStream extends FilterOutputStream {
|
|||||||
buf[count++] = ((byte)(0x80 | ((uc >> 6) & 0x3f)));
|
buf[count++] = ((byte)(0x80 | ((uc >> 6) & 0x3f)));
|
||||||
buf[count++] = ((byte)(0x80 | (uc & 0x3f)));
|
buf[count++] = ((byte)(0x80 | (uc & 0x3f)));
|
||||||
} else {
|
} else {
|
||||||
if(3 < buf.length - count) {
|
if(3 >= buf.length - count) {
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
}
|
}
|
||||||
buf[count++] =((byte)(0xe0 | ((c >> 12))));
|
buf[count++] =((byte)(0xe0 | ((c >> 12))));
|
||||||
|
|||||||
Reference in New Issue
Block a user