aboutsummaryrefslogtreecommitdiff
path: root/inffast.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:20:42 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:20:42 -0700
commita383133c4e7b93113cee912f213cf9502d785fa7 (patch)
treebb7c39ab38418fcab817accad1e625b3de0c8237 /inffast.c
parent14763ac7c6c03bca62c39e35c03cf5bfc7728802 (diff)
downloadzlib-a383133c4e7b93113cee912f213cf9502d785fa7.tar.gz
zlib-a383133c4e7b93113cee912f213cf9502d785fa7.tar.bz2
zlib-a383133c4e7b93113cee912f213cf9502d785fa7.zip
zlib 1.1.4v1.1.4
Diffstat (limited to 'inffast.c')
-rw-r--r--inffast.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/inffast.c b/inffast.c
index 61a78ee..aa7f1d4 100644
--- a/inffast.c
+++ b/inffast.c
@@ -1,5 +1,5 @@
1/* inffast.c -- process literals and length/distance pairs fast 1/* inffast.c -- process literals and length/distance pairs fast
2 * Copyright (C) 1995-1998 Mark Adler 2 * Copyright (C) 1995-2002 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -93,28 +93,41 @@ z_streamp z;
93 93
94 /* do the copy */ 94 /* do the copy */
95 m -= c; 95 m -= c;
96 if ((uInt)(q - s->window) >= d) /* offset before dest */ 96 r = q - d;
97 { /* just copy */ 97 if (r < s->window) /* wrap if needed */
98 r = q - d;
99 *q++ = *r++; c--; /* minimum count is three, */
100 *q++ = *r++; c--; /* so unroll loop a little */
101 }
102 else /* else offset after destination */
103 { 98 {
104 e = d - (uInt)(q - s->window); /* bytes from offset to end */ 99 do {
105 r = s->end - e; /* pointer to offset */ 100 r += s->end - s->window; /* force pointer in window */
106 if (c > e) /* if source crosses, */ 101 } while (r < s->window); /* covers invalid distances */
102 e = s->end - r;
103 if (c > e)
107 { 104 {
108 c -= e; /* copy to end of window */ 105 c -= e; /* wrapped copy */
109 do { 106 do {
110 *q++ = *r++; 107 *q++ = *r++;
111 } while (--e); 108 } while (--e);
112 r = s->window; /* copy rest from start of window */ 109 r = s->window;
110 do {
111 *q++ = *r++;
112 } while (--c);
113 } 113 }
114 else /* normal copy */
115 {
116 *q++ = *r++; c--;
117 *q++ = *r++; c--;
118 do {
119 *q++ = *r++;
120 } while (--c);
121 }
122 }
123 else /* normal copy */
124 {
125 *q++ = *r++; c--;
126 *q++ = *r++; c--;
127 do {
128 *q++ = *r++;
129 } while (--c);
114 } 130 }
115 do { /* copy all or what's left */
116 *q++ = *r++;
117 } while (--c);
118 break; 131 break;
119 } 132 }
120 else if ((e & 64) == 0) 133 else if ((e & 64) == 0)