Commit bfcf81ec authored by Jörn Engel's avatar Jörn Engel Committed by Linus Torvalds

[PATCH] zlib merge: inffast.c

Most of it is reformatting, but the functional bits should fix real
problems.  A loop is introduced, just like in the turboc patch and one
of the three condition bodies has been expanded.
parent 68a37fb3
...@@ -90,28 +90,41 @@ int zlib_inflate_fast( ...@@ -90,28 +90,41 @@ int zlib_inflate_fast(
/* do the copy */ /* do the copy */
m -= c; m -= c;
if ((uInt)(q - s->window) >= d) /* offset before dest */ r = q - d;
{ /* just copy */ if (r < s->window) /* wrap if needed */
r = q - d;
*q++ = *r++; c--; /* minimum count is three, */
*q++ = *r++; c--; /* so unroll loop a little */
}
else /* else offset after destination */
{ {
e = d - (uInt)(q - s->window); /* bytes from offset to end */ do {
r = s->end - e; /* pointer to offset */ r += s->end - s->window; /* force pointer in window */
if (c > e) /* if source crosses, */ } while (r < s->window); /* covers invalid distances */
e = s->end - r;
if (c > e)
{ {
c -= e; /* copy to end of window */ c -= e; /* wrapped copy */
do { do {
*q++ = *r++; *q++ = *r++;
} while (--e); } while (--e);
r = s->window; /* copy rest from start of window */ r = s->window;
do {
*q++ = *r++;
} while (--c);
} }
else /* normal copy */
{
*q++ = *r++; c--;
*q++ = *r++; c--;
do {
*q++ = *r++;
} while (--c);
}
}
else /* normal copy */
{
*q++ = *r++; c--;
*q++ = *r++; c--;
do {
*q++ = *r++;
} while (--c);
} }
do { /* copy all or what's left */
*q++ = *r++;
} while (--c);
break; break;
} }
else if ((e & 64) == 0) else if ((e & 64) == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment