mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-14 07:24:32 +00:00
OPTIM: hpack: read 32 bits at once when possible.
As suggested in the comment, it's possible to read 32 bits at once in big-endian order, and now we have the functions to do this, so let's do it. This reduces the code on the fast path by 31 bytes on x86, and more importantly performs single-operation 32-bit reads instead of playing with shifts and additions.
This commit is contained in:
parent
17b4687a89
commit
fcce0e1e09
@ -31,6 +31,7 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/hpack-huff.h>
|
||||
#include <haproxy/net_helper.h>
|
||||
|
||||
struct huff {
|
||||
uint32_t c; /* code point */
|
||||
@ -1439,17 +1440,11 @@ int huff_dec(const uint8_t *huff, int hlen, char *out, int olen)
|
||||
while (shift >= 32) {
|
||||
curr = next;
|
||||
|
||||
/* read up to 4 bytes into next. FIXME: this should
|
||||
* later be optimized to perform a single 32-bit big
|
||||
* endian read when unaligned accesses are possible.
|
||||
*/
|
||||
/* read up to 4 bytes into next */
|
||||
next = 0;
|
||||
|
||||
if (huff + 4 <= huff_end) {
|
||||
next = ((uint32_t)huff[0] << 24) +
|
||||
((uint32_t)huff[1] << 16) +
|
||||
((uint32_t)huff[2] << 8) +
|
||||
(uint32_t)huff[3];
|
||||
next = read_n32(huff);
|
||||
huff += 4;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user