Transpile Java speedup (#548)

This commit is contained in:
Eugene Kliuchnikov 2017-05-07 17:40:12 +02:00 committed by GitHub
parent 4363f2d74b
commit 0a84e9bf86

View File

@ -852,19 +852,34 @@ namespace Org.Brotli.Dec
case Org.Brotli.Dec.RunningState.CopyLoop: case Org.Brotli.Dec.RunningState.CopyLoop:
{ {
// fall through // fall through
for (; state.j < state.copyLength; ) int src = (state.pos - state.distance) & ringBufferMask;
int dst = state.pos;
int copyLength = state.copyLength - state.j;
if ((src + copyLength < ringBufferMask) && (dst + copyLength < ringBufferMask))
{ {
ringBuffer[state.pos] = ringBuffer[(state.pos - state.distance) & ringBufferMask]; for (int k = 0; k < copyLength; ++k)
// TODO: condense
state.metaBlockLength--;
state.j++;
if (state.pos++ == ringBufferMask)
{ {
state.nextRunningState = Org.Brotli.Dec.RunningState.CopyLoop; ringBuffer[dst++] = ringBuffer[src++];
state.bytesToWrite = state.ringBufferSize; }
state.bytesWritten = 0; state.j += copyLength;
state.runningState = Org.Brotli.Dec.RunningState.Write; state.metaBlockLength -= copyLength;
break; state.pos += copyLength;
}
else
{
for (; state.j < state.copyLength; )
{
ringBuffer[state.pos] = ringBuffer[(state.pos - state.distance) & ringBufferMask];
state.metaBlockLength--;
state.j++;
if (state.pos++ == ringBufferMask)
{
state.nextRunningState = Org.Brotli.Dec.RunningState.CopyLoop;
state.bytesToWrite = state.ringBufferSize;
state.bytesWritten = 0;
state.runningState = Org.Brotli.Dec.RunningState.Write;
break;
}
} }
} }
if (state.runningState == Org.Brotli.Dec.RunningState.CopyLoop) if (state.runningState == Org.Brotli.Dec.RunningState.CopyLoop)