mirror of
https://github.com/google/brotli.git
synced 2024-11-22 03:30:07 +00:00
Speedup Java decoder. (#547)
* geo corpus decodes ~5% faster * fetchlogs corpus decodes ~25% faster
This commit is contained in:
parent
a015b42683
commit
4363f2d74b
@ -759,10 +759,20 @@ final class Decode {
|
|||||||
state.runningState = COPY_LOOP;
|
state.runningState = COPY_LOOP;
|
||||||
// fall through
|
// fall through
|
||||||
case COPY_LOOP:
|
case COPY_LOOP:
|
||||||
|
int src = (state.pos - state.distance) & ringBufferMask;
|
||||||
|
int dst = state.pos;
|
||||||
|
int copyLength = state.copyLength - state.j;
|
||||||
|
if ((src + copyLength < ringBufferMask) && (dst + copyLength < ringBufferMask)) {
|
||||||
|
for (int k = 0; k < copyLength; ++k) {
|
||||||
|
ringBuffer[dst++] = ringBuffer[src++];
|
||||||
|
}
|
||||||
|
state.j += copyLength;
|
||||||
|
state.metaBlockLength -= copyLength;
|
||||||
|
state.pos += copyLength;
|
||||||
|
} else {
|
||||||
for (; state.j < state.copyLength;) {
|
for (; state.j < state.copyLength;) {
|
||||||
ringBuffer[state.pos] =
|
ringBuffer[state.pos] =
|
||||||
ringBuffer[(state.pos - state.distance) & ringBufferMask];
|
ringBuffer[(state.pos - state.distance) & ringBufferMask];
|
||||||
// TODO: condense
|
|
||||||
state.metaBlockLength--;
|
state.metaBlockLength--;
|
||||||
state.j++;
|
state.j++;
|
||||||
if (state.pos++ == ringBufferMask) {
|
if (state.pos++ == ringBufferMask) {
|
||||||
@ -773,6 +783,7 @@ final class Decode {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (state.runningState == COPY_LOOP) {
|
if (state.runningState == COPY_LOOP) {
|
||||||
state.runningState = MAIN_LOOP;
|
state.runningState = MAIN_LOOP;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user