ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/liblzf/lzf_c.c
(Generate patch)

Comparing liblzf/lzf_c.c (file contents):
Revision 1.41 by root, Tue Jun 1 02:30:06 2010 UTC vs.
Revision 1.42 by root, Tue Jun 1 03:17:06 2010 UTC

104 ) 104 )
105{ 105{
106#if !LZF_STATE_ARG 106#if !LZF_STATE_ARG
107 LZF_STATE htab; 107 LZF_STATE htab;
108#endif 108#endif
109 const u8 **hslot;
110 const u8 *ip = (const u8 *)in_data; 109 const u8 *ip = (const u8 *)in_data;
111 u8 *op = (u8 *)out_data; 110 u8 *op = (u8 *)out_data;
112 const u8 *in_end = ip + in_len; 111 const u8 *in_end = ip + in_len;
113 u8 *out_end = op + out_len; 112 u8 *out_end = op + out_len;
114 const u8 *ref; 113 const u8 *ref;
131 if (!in_len || !out_len) 130 if (!in_len || !out_len)
132 return 0; 131 return 0;
133 132
134#if INIT_HTAB 133#if INIT_HTAB
135 memset (htab, 0, sizeof (htab)); 134 memset (htab, 0, sizeof (htab));
136# if 0
137 for (hslot = htab; hslot < htab + HSIZE; hslot++)
138 *hslot++ = ip;
139# endif
140#endif 135#endif
141 136
142 lit = 0; op++; /* start run */ 137 lit = 0; op++; /* start run */
143 138
144 hval = FRST (ip); 139 hval = FRST (ip);
145 while (ip < in_end - 2) 140 while (ip < in_end - 2)
146 { 141 {
142 LZF_HSLOT *hslot;
143
147 hval = NEXT (hval, ip); 144 hval = NEXT (hval, ip);
148 hslot = htab + IDX (hval); 145 hslot = htab + IDX (hval);
149 ref = *hslot; *hslot = ip; 146 ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS;
150 147
151 if (1 148 if (1
152#if INIT_HTAB 149#if INIT_HTAB
153 && ref < ip /* the next test will actually take care of this, but this is faster */ 150 && ref < ip /* the next test will actually take care of this, but this is faster */
154#endif 151#endif
234 --ip; 231 --ip;
235# endif 232# endif
236 hval = FRST (ip); 233 hval = FRST (ip);
237 234
238 hval = NEXT (hval, ip); 235 hval = NEXT (hval, ip);
239 htab[IDX (hval)] = ip; 236 htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
240 ip++; 237 ip++;
241 238
242# if VERY_FAST && !ULTRA_FAST 239# if VERY_FAST && !ULTRA_FAST
243 hval = NEXT (hval, ip); 240 hval = NEXT (hval, ip);
244 htab[IDX (hval)] = ip; 241 htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
245 ip++; 242 ip++;
246# endif 243# endif
247#else 244#else
248 ip -= len + 1; 245 ip -= len + 1;
249 246
250 do 247 do
251 { 248 {
252 hval = NEXT (hval, ip); 249 hval = NEXT (hval, ip);
253 htab[IDX (hval)] = ip; 250 htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
254 ip++; 251 ip++;
255 } 252 }
256 while (len--); 253 while (len--);
257#endif 254#endif
258 } 255 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines