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.16 by root, Mon Nov 5 23:28:40 2007 UTC vs.
Revision 1.17 by root, Tue Nov 13 07:54:18 2007 UTC

75 asm ("rep movsb" \ 75 asm ("rep movsb" \
76 : "=D" (dst), "=S" (src), "=c" (len) \ 76 : "=D" (dst), "=S" (src), "=c" (len) \
77 : "0" (dst), "1" (src), "2" (len)); 77 : "0" (dst), "1" (src), "2" (len));
78#endif 78#endif
79 79
80#if __GNUC__ >= 3
81# define expect(expr,value) __builtin_expect ((expr),(value))
82# define inline inline
83#else
84# define expect(expr,value) (expr)
85# define inline static
86#endif
87
88#define expect_false(expr) expect ((expr) != 0, 0)
89#define expect_true(expr) expect ((expr) != 0, 1)
90
80/* 91/*
81 * compressed format 92 * compressed format
82 * 93 *
83 * 000LLLLL <L+1> ; literal 94 * 000LLLLL <L+1> ; literal
84 * LLLooooo oooooooo ; backref L 95 * LLLooooo oooooooo ; backref L
116# endif 127# endif
117#endif 128#endif
118 129
119 for (;;) 130 for (;;)
120 { 131 {
121 if (ip < in_end - 2) 132 if (expect_true (ip < in_end - 2))
122 { 133 {
123 hval = NEXT (hval, ip); 134 hval = NEXT (hval, ip);
124 hslot = htab + IDX (hval); 135 hslot = htab + IDX (hval);
125 ref = *hslot; *hslot = ip; 136 ref = *hslot; *hslot = ip;
126 137
144 /* match found at *ref++ */ 155 /* match found at *ref++ */
145 unsigned int len = 2; 156 unsigned int len = 2;
146 unsigned int maxlen = in_end - ip - len; 157 unsigned int maxlen = in_end - ip - len;
147 maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; 158 maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
148 159
149 if (op + lit + 1 + 3 >= out_end) 160 if (expect_false (op + lit + 1 + 3 >= out_end))
150 return 0; 161 return 0;
151 162
152 do 163 do
153 len++; 164 len++;
154 while (len < maxlen && ref[len] == ip[len]); 165 while (len < maxlen && ref[len] == ip[len]);
203 while (len--); 214 while (len--);
204#endif 215#endif
205 continue; 216 continue;
206 } 217 }
207 } 218 }
208 else if (ip == in_end) 219 else if (expect_false (ip == in_end))
209 break; 220 break;
210 221
211 /* one more literal byte we must copy */ 222 /* one more literal byte we must copy */
212 lit++; 223 lit++;
213 ip++; 224 ip++;
214 225
215 if (lit == MAX_LIT) 226 if (expect_false (lit == MAX_LIT))
216 { 227 {
217 if (op + 1 + MAX_LIT >= out_end) 228 if (op + 1 + MAX_LIT >= out_end)
218 return 0; 229 return 0;
219 230
220 *op++ = MAX_LIT - 1; 231 *op++ = MAX_LIT - 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines