java-topology/defects/envoy/patch/0001-previous-hosts-use-flat-hash-set.patch

30 lines
1.2 KiB
Diff

# UNDF: UNDF-2026-000000063
diff --git a/source/extensions/retry/host/previous_hosts/previous_hosts.h b/source/extensions/retry/host/previous_hosts/previous_hosts.h
index 1234567..abcdef0 100644
--- a/source/extensions/retry/host/previous_hosts/previous_hosts.h
+++ b/source/extensions/retry/host/previous_hosts/previous_hosts.h
@@ -1,18 +1,20 @@
#pragma once
#include "envoy/upstream/retry.h"
#include "envoy/upstream/upstream.h"
+#include "absl/container/flat_hash_set.h"
namespace Envoy {
class PreviousHostsRetryPredicate : public Upstream::RetryHostPredicate {
public:
bool shouldSelectAnotherHost(const Upstream::Host& candidate_host) override {
- return std::find(attempted_hosts_.begin(), attempted_hosts_.end(), &candidate_host) !=
- attempted_hosts_.end();
+ return attempted_hosts_.contains(&candidate_host);
}
void onHostAttempted(Upstream::HostDescriptionConstSharedPtr attempted_host) override {
- attempted_hosts_.emplace_back(attempted_host.get());
+ attempted_hosts_.insert(attempted_host.get());
}
private:
- std::vector<Upstream::HostDescription const*> attempted_hosts_;
+ absl::flat_hash_set<Upstream::HostDescription const*> attempted_hosts_;
};
} // namespace Envoy