java-topology/defects/envoy/patch/envoy-0004-http2-settings-dedup-linear-scan.patch
russell@unturf.com 25c2bafdee undf: assign 694-720; stamp patches; ruby-0003/elixir-0002/r-source-0002/victoria-metrics-0002
New UNDF assignments (693→720):
  elixir-0002 → UNDF-2026-000000698 (typespec used_type_pairs O(T²))
  r-source-0002 → UNDF-2026-000000711 (.walkClassGraph match dedup O(S²))
  ruby-0003 → UNDF-2026-000000712 (RubyGems dependent_gems O(N²×D))
  victoria-metrics-0002 → UNDF-2026-000000717 (MetricName tag-filter O(T×I))

Total: 720 UNDF assigned
2026-03-29 22:28:31 -04:00

67 lines
3.6 KiB
Diff

# UNDF: UNDF-2026-000000699
--- a/source/common/http/http2/codec_impl.cc
+++ b/source/common/http/http2/codec_impl.cc
@@ -1730,35 +1730,35 @@ void ConnectionImpl::sendSettingsHelper(
const envoy::config::core::v3::Http2ProtocolOptions& http2_options, bool disable_push) {
- absl::InlinedVector<http2::adapter::Http2Setting, 10> settings;
- auto insertParameter = [&settings](const http2::adapter::Http2Setting& entry) mutable -> bool {
- // Consider using a set as an intermediate data structure, rather than this ad-hoc
- // deduplication.
- const auto it = std::find_if(
- settings.cbegin(), settings.cend(),
- [&entry](const http2::adapter::Http2Setting& existing) { return entry.id == existing.id; });
- if (it != settings.end()) {
- return false;
- }
- settings.push_back(entry);
- return true;
- };
+ // Use flat_hash_map for O(1) per-insertion dedup instead of O(S) std::find_if.
+ // Previously flagged with: "Consider using a set as an intermediate data structure."
+ absl::flat_hash_map<uint16_t, uint32_t> settings_dedup;
+ auto insertParameter = [&settings_dedup](const http2::adapter::Http2Setting& entry) mutable -> bool {
+ return settings_dedup.emplace(static_cast<uint16_t>(entry.id), entry.value).second;
+ };
// Universally disable receiving push promise frames as we don't currently
// support them.
// NOTE: This is a special case with respect to custom parameter overrides in
// that server push is not supported and therefore not end user configurable.
if (disable_push) {
- settings.push_back({static_cast<int32_t>(http2::adapter::ENABLE_PUSH), disable_push ? 0U : 1U});
+ insertParameter({http2::adapter::ENABLE_PUSH, disable_push ? 0U : 1U});
}
for (const auto& it : http2_options.custom_settings_parameters()) {
ASSERT(it.identifier().value() <= std::numeric_limits<uint16_t>::max());
const bool result =
insertParameter({static_cast<http2::adapter::Http2SettingsId>(it.identifier().value()),
it.value().value()});
ASSERT(result);
ENVOY_CONN_LOG(debug, "adding custom settings parameter with id {:#x} to {}", connection_,
it.identifier().value(), it.value().value());
}
- // Insert named parameters.
- settings.insert(
- settings.end(),
- {{http2::adapter::HEADER_TABLE_SIZE, http2_options.hpack_table_size().value()},
- {http2::adapter::ENABLE_CONNECT_PROTOCOL, http2_options.allow_connect()},
- {http2::adapter::MAX_CONCURRENT_STREAMS, http2_options.max_concurrent_streams().value()},
- {http2::adapter::INITIAL_WINDOW_SIZE, http2_options.initial_stream_window_size().value()}});
- adapter_->SubmitSettings(settings);
+ // Insert named parameters (these are always present; insertParameter handles
+ // dedup if a custom_settings_parameters entry conflicts).
+ insertParameter({http2::adapter::HEADER_TABLE_SIZE, http2_options.hpack_table_size().value()});
+ insertParameter({http2::adapter::ENABLE_CONNECT_PROTOCOL, http2_options.allow_connect()});
+ insertParameter({http2::adapter::MAX_CONCURRENT_STREAMS, http2_options.max_concurrent_streams().value()});
+ insertParameter({http2::adapter::INITIAL_WINDOW_SIZE, http2_options.initial_stream_window_size().value()});
+
+ // Convert dedup map to vector for SubmitSettings.
+ absl::InlinedVector<http2::adapter::Http2Setting, 10> settings;
+ settings.reserve(settings_dedup.size());
+ for (const auto& [id, value] : settings_dedup) {
+ settings.push_back({static_cast<http2::adapter::Http2SettingsId>(id), value});
+ }
+ adapter_->SubmitSettings(settings);
}