|
7 | 7 |
|
8 | 8 | Implements the version dated January 9, 2014.
|
9 | 9 | """
|
| 10 | +import collections |
| 11 | + |
10 | 12 | from .huffman import HuffmanDecoder, HuffmanEncoder
|
11 | 13 | from hyper.http20.huffman_constants import (
|
12 | 14 | REQUEST_CODES, REQUEST_CODES_LENGTH, RESPONSE_CODES, RESPONSE_CODES_LENGTH
|
@@ -148,7 +150,7 @@ class Encoder(object):
|
148 | 150 | ]
|
149 | 151 |
|
150 | 152 | def __init__(self):
|
151 |
| - self.header_table = [] |
| 153 | + self.header_table = collections.deque() |
152 | 154 | self.reference_set = set()
|
153 | 155 | self._header_table_size = 4096 # This value set by the standard.
|
154 | 156 | self.huffman_coder = HuffmanEncoder(
|
@@ -342,7 +344,7 @@ def _add_to_header_table(self, name, value):
|
342 | 344 | Adds a header to the header table, evicting old ones if necessary.
|
343 | 345 | """
|
344 | 346 | # Be optimistic: add the header straight away.
|
345 |
| - self.header_table.insert(0, (name, value)) |
| 347 | + self.header_table.appendleft((name, value)) |
346 | 348 |
|
347 | 349 | # Now, work out how big the header table is.
|
348 | 350 | actual_size = header_table_size(self.header_table)
|
@@ -478,7 +480,7 @@ class Decoder(object):
|
478 | 480 | ]
|
479 | 481 |
|
480 | 482 | def __init__(self):
|
481 |
| - self.header_table = [] |
| 483 | + self.header_table = collections.deque() |
482 | 484 | self.reference_set = set()
|
483 | 485 | self._header_table_size = 4096 # This value set by the standard.
|
484 | 486 | self.huffman_coder = HuffmanDecoder(
|
@@ -553,7 +555,7 @@ def _add_to_header_table(self, name, value):
|
553 | 555 | Adds a header to the header table, evicting old ones if necessary.
|
554 | 556 | """
|
555 | 557 | # Be optimistic: add the header straight away.
|
556 |
| - self.header_table.insert(0, (name, value)) |
| 558 | + self.header_table.appendleft((name, value)) |
557 | 559 |
|
558 | 560 | # Now, work out how big the header table is.
|
559 | 561 | actual_size = header_table_size(self.header_table)
|
|
0 commit comments