summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJörn Engel <joern@wohnheim.fh-wedel.de>2003-06-07 19:30:52 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2003-06-07 19:30:52 -0700
commitbfcf81ec73085be993cf98f9ae6212ae29af891a (patch)
tree324abf2dec716a02f0886d4e950d252a604da224 /lib
parent68a37fb3e0595545d5f08d3c33117c1d1edc39df (diff)
[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.
Diffstat (limited to 'lib')
-rw-r--r--lib/zlib_inflate/inffast.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c
index f8fd07715fd6..0bd7623fc85a 100644
--- a/lib/zlib_inflate/inffast.c
+++ b/lib/zlib_inflate/inffast.c
@@ -90,28 +90,41 @@ int zlib_inflate_fast(
/* do the copy */
m -= c;
- if ((uInt)(q - s->window) >= d) /* offset before dest */
- { /* just copy */
- r = q - d;
- *q++ = *r++; c--; /* minimum count is three, */
- *q++ = *r++; c--; /* so unroll loop a little */
- }
- else /* else offset after destination */
+ r = q - d;
+ if (r < s->window) /* wrap if needed */
{
- e = d - (uInt)(q - s->window); /* bytes from offset to end */
- r = s->end - e; /* pointer to offset */
- if (c > e) /* if source crosses, */
+ do {
+ r += s->end - s->window; /* force pointer in window */
+ } 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 {
- *q++ = *r++;
+ *q++ = *r++;
} 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;
}
else if ((e & 64) == 0)