Use circular buffer instead of std::deque for HPACK dynamic table in HTTP/2 decoder.
Http2Deque is an alias for QuicheDequeImpl which is an alias for std::deque both
in internal code and in Chromium. QuicCircularDeque is more memory efficient,
especially if there are only few entries, and requires fewer allocations as new
entries are added if old entries are also being removed, which is the case for
HPACK where the dynamic table size is bounded.
PiperOrigin-RevId: 366295336
Change-Id: I9457344c632ae26def506592d64a3d233cb380c1
diff --git a/http2/hpack/decoder/hpack_decoder_tables.h b/http2/hpack/decoder/hpack_decoder_tables.h
index 45fce60..f75916d 100644
--- a/http2/hpack/decoder/hpack_decoder_tables.h
+++ b/http2/hpack/decoder/hpack_decoder_tables.h
@@ -25,7 +25,7 @@
#include <vector>
#include "http2/http2_constants.h"
-#include "http2/platform/api/http2_containers.h"
+#include "quic/core/quic_circular_deque.h"
#include "common/platform/api/quiche_export.h"
namespace http2 {
@@ -107,7 +107,7 @@
// Removes the oldest dynamic table entry.
void RemoveLastEntry();
- Http2Deque<HpackStringPair> table_;
+ quic::QuicCircularDeque<HpackStringPair> table_;
// The last received DynamicTableSizeUpdate value, initialized to
// SETTINGS_HEADER_TABLE_SIZE.