nghttp2_hd_huffman: Avoid memset on encoding
This commit is contained in:
parent
8cd2b57f8a
commit
0d6faa74b7
|
@ -128,11 +128,12 @@ static size_t huff_encode_sym(uint8_t **dest_ptr, size_t bitoff,
|
||||||
const nghttp2_huff_sym *sym)
|
const nghttp2_huff_sym *sym)
|
||||||
{
|
{
|
||||||
size_t b = 0;
|
size_t b = 0;
|
||||||
|
if(bitoff == 0) **dest_ptr = 0;
|
||||||
**dest_ptr |= huff_get_lsb_aligned(sym, b, 8 - bitoff);
|
**dest_ptr |= huff_get_lsb_aligned(sym, b, 8 - bitoff);
|
||||||
b += 8 - bitoff;
|
b += 8 - bitoff;
|
||||||
++*dest_ptr;
|
++*dest_ptr;
|
||||||
for(; b < sym->nbits; b += 8, ++*dest_ptr) {
|
for(; b < sym->nbits; b += 8, ++*dest_ptr) {
|
||||||
**dest_ptr |= huff_get_lsb_aligned(sym, b, 8);
|
**dest_ptr = huff_get_lsb_aligned(sym, b, 8);
|
||||||
}
|
}
|
||||||
bitoff = 8 - (b - sym->nbits);
|
bitoff = 8 - (b - sym->nbits);
|
||||||
if(bitoff > 0) {
|
if(bitoff > 0) {
|
||||||
|
@ -174,7 +175,6 @@ ssize_t nghttp2_hd_huff_encode(uint8_t *dest, size_t destlen,
|
||||||
} else {
|
} else {
|
||||||
huff_sym_table = res_huff_sym_table;
|
huff_sym_table = res_huff_sym_table;
|
||||||
}
|
}
|
||||||
memset(dest, 0, destlen);
|
|
||||||
for(i = 0; i < srclen; ++i) {
|
for(i = 0; i < srclen; ++i) {
|
||||||
const nghttp2_huff_sym *sym = &huff_sym_table[src[i]];
|
const nghttp2_huff_sym *sym = &huff_sym_table[src[i]];
|
||||||
bitoff = huff_encode_sym(&dest, bitoff, sym);
|
bitoff = huff_encode_sym(&dest, bitoff, sym);
|
||||||
|
|
Loading…
Reference in New Issue