Index: trunk/willow/src/include/willow.h |
— | — | @@ -82,8 +82,8 @@ |
83 | 83 | extern int char_table[]; |
84 | 84 | |
85 | 85 | #if defined(__GNUC__) || defined(__INTEL_COMPILER) |
86 | | -# define likely(c) __builtin_expect((c), 1) |
87 | | -# define unlikely(c) __builtin_expect((c), 0) |
| 86 | +# define likely(c) __builtin_expect((c), true) |
| 87 | +# define unlikely(c) __builtin_expect((c), false) |
88 | 88 | #else |
89 | 89 | # define likely(c) c |
90 | 90 | # define unlikely(c) c |
Index: trunk/willow/src/willow/whttp_header.cc |
— | — | @@ -292,14 +292,14 @@ |
293 | 293 | size_t vlen, nlen, rnpos; |
294 | 294 | while ((rn = find_rn(bufp, bufp + len)) != NULL) { |
295 | 295 | for (char const *c = bufp; c < rn; ++c) |
296 | | - if (*(unsigned char *)c > 0x7f || !*c) |
| 296 | + if (unlikely(*(unsigned char *)c > 0x7f || !*c)) |
297 | 297 | return io::sink_result_error; |
298 | 298 | |
299 | 299 | if (rn == bufp) { |
300 | 300 | _sink_spigot->sp_cork(); |
301 | 301 | discard += bufp - buf + 2; |
302 | 302 | /* request with no request is an error */ |
303 | | - if (!_got_reqtype) |
| 303 | + if (unlikely(!_got_reqtype)) |
304 | 304 | return io::sink_result_error; |
305 | 305 | else { |
306 | 306 | if (!_is_response && _http_host.empty()) { |
— | — | @@ -317,14 +317,15 @@ |
318 | 318 | name = bufp; |
319 | 319 | |
320 | 320 | if (!_got_reqtype) { |
321 | | - if ((!_is_response && parse_reqtype(bufp, rn) == -1) |
322 | | - || (_is_response && parse_response(bufp, rn) == -1)) { |
| 321 | + if (unlikely((!_is_response && parse_reqtype(bufp, rn) == -1) |
| 322 | + || (_is_response && parse_response(bufp, rn) == -1))) { |
323 | 323 | _sink_spigot->sp_cork(); |
324 | 324 | return io::sink_result_error; |
325 | 325 | } |
326 | 326 | _got_reqtype = true; |
327 | 327 | goto next; |
328 | 328 | } |
| 329 | + |
329 | 330 | if (*name == ' ') { |
330 | 331 | const char *s = name; |
331 | 332 | /* continuation of last header */ |
— | — | @@ -337,7 +338,7 @@ |
338 | 339 | goto next; |
339 | 340 | } |
340 | 341 | |
341 | | - if ((value = (const char *)memchr(name, ':', rnpos)) == NULL) { |
| 342 | + if (unlikely((value = (const char *)memchr(name, ':', rnpos)) == NULL)) { |
342 | 343 | _sink_spigot->sp_cork(); |
343 | 344 | return io::sink_result_error; |
344 | 345 | } |