Skip to main content

Module decode

Module decode 

Source
Expand description

Huffman decoding for HPACK (RFC 7541 ยง5.2).

The decoder has a fast path which decodes 12 bits a time. The decoder looks the next 12 bits up in FAST_TABLE, which maps directly to either one or two symbols to decode. Since ASCII letters and digits have 5-7 bit codes, one lookup usually decodes two symbols at once.

Two situations fall off this fast path:

  • Codes longer than 12 bits: control characters and bytes >= 0x80
  • The end of the input, when fewer than 12 bits remain.

These are decoded by walking the generated DECODE_TABLE one input byte at a time.

Constantsยง

BRANCH ๐Ÿ”’
FAST_BITS ๐Ÿ”’
FAST_DECODE_TABLE ๐Ÿ”’
TABLE_INDEX_MASK ๐Ÿ”’
TABLE_WIDTH ๐Ÿ”’

Functionsยง

build_fast_table ๐Ÿ”’
decode
decode_code_slow ๐Ÿ”’