Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Checks: >
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
readability-braces-around-statements,
readability-container-contains,
readability-container-size-empty,
readability-identifier-naming,
readability-redundant-control-flow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AllowedPrincipals : public ThreadLocal::ThreadLocalObject {
}
}
bool allowed(const std::string& sha256_digest) const {
return allowed_sha256_digests_.count(sha256_digest) != 0;
return allowed_sha256_digests_.contains(sha256_digest);
}
size_t size() const { return allowed_sha256_digests_.size(); }

Expand Down
2 changes: 1 addition & 1 deletion contrib/exe/contrib_version_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST(ContribVersionTest, VersionContainsSuffix) {
TEST(ContribVersionTest, BuildVersionContainsSuffix) {
auto build_version = VersionInfo::buildVersion();
const auto& fields = build_version.metadata().fields();
ASSERT_NE(fields.find(BuildVersionMetadataKeys::get().BuildLabel), fields.end());
ASSERT_TRUE(fields.contains(BuildVersionMetadataKeys::get().BuildLabel));
EXPECT_THAT(fields.at(BuildVersionMetadataKeys::get().BuildLabel).string_value(),
testing::EndsWith("contrib"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ UpstreamKafkaConfigurationImpl::UpstreamKafkaConfigurationImpl(const KafkaMeshPr
const std::string& cluster_name = upstream_cluster_definition.cluster_name();

// No duplicates are allowed.
if (cluster_name_to_cluster_config.find(cluster_name) != cluster_name_to_cluster_config.end()) {
if (cluster_name_to_cluster_config.contains(cluster_name)) {
throw EnvoyException(
absl::StrCat("kafka-mesh filter has multiple Kafka clusters referenced by the same name",
cluster_name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ TEST_F(KafkaMetricsFacadeImplUnitTest, ShouldRegisterResponse) {

// then
const auto& request_arrivals = testee_.getRequestArrivalsForTest();
ASSERT_EQ(request_arrivals.find(correlation_id), request_arrivals.end());
ASSERT_FALSE(request_arrivals.contains(correlation_id));
}

TEST_F(KafkaMetricsFacadeImplUnitTest, ShouldRegisterUnknownResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@ void DecoderImpl::onStartup() {
attributes_ = absl::StrSplit(message_.substr(4), absl::ByChar('\0'), absl::SkipEmpty());

// If "database" attribute is not found, default it to "user" attribute.
if ((attributes_.find("database") == attributes_.end()) &&
(attributes_.find("user") != attributes_.end())) {
if (!attributes_.contains("database") && attributes_.contains("user")) {
attributes_["database"] = attributes_["user"];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void ActiveMessage::fillBrokerData(std::vector<BrokerData>& list, const std::str
for (auto& entry : list) {
if (entry.cluster() == cluster && entry.brokerName() == broker_name) {
found = true;
if (entry.brokerAddresses().find(broker_id) != entry.brokerAddresses().end()) {
if (entry.brokerAddresses().contains(broker_id)) {
ENVOY_LOG(warn, "Duplicate broker_id found. Broker ID: {}, address: {}", broker_id,
address);
continue;
Expand Down
4 changes: 2 additions & 2 deletions contrib/sip_proxy/filters/network/source/conn_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void ConnectionManager::sendLocalReply(MessageMetadata& metadata, const DirectRe
}

void ConnectionManager::setLocalResponseSent(absl::string_view transaction_id) {
if (transactions_.find(transaction_id) != transactions_.end()) {
if (transactions_.contains(transaction_id)) {
transactions_[transaction_id]->setLocalResponseSent(true);
}
}
Expand Down Expand Up @@ -357,7 +357,7 @@ DecoderEventHandler& ConnectionManager::newDecoderEventHandler(MessageMetadataSh

std::string&& k = std::string(metadata->transactionId().value());
// if (metadata->methodType() == MethodType::Ack) {
if (transactions_.find(k) != transactions_.end()) {
if (transactions_.contains(k)) {
// ACK_4XX metadata will updated later.
return *transactions_.at(k);
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/sip_proxy/filters/network/source/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ template <typename K, typename V> class Cache {
}
}

bool contains(const K& key) { return cache_.find(key) != cache_.end(); }
bool contains(const K& key) { return cache_.contains(key); }

OptRef<V> at(const K& key) {
auto it = cache_.find(key);
Expand Down
2 changes: 1 addition & 1 deletion contrib/sxg/filters/http/source/encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool EncoderImpl::loadHeaders(Http::ResponseHeaderMap* headers) {
}
}
// filter out headers that are not allowed to be encoded in the SXG document
if (filtered_headers.find(header_key) != filtered_headers.end()) {
if (filtered_headers.contains(header_key)) {
return Http::HeaderMap::Iterate::Continue;
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/vcl/source/vcl_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void vclInterfaceRegisterEpollEvent(Envoy::Event::Dispatcher& dispatcher) {
MqFileEventsMap& mq_fevts_map = mqFileEventsMap();
const int wrk_index = vppcom_worker_index();
RELEASE_ASSERT(wrk_index != -1, "");
if (mq_fevts_map.find(wrk_index) != mq_fevts_map.end()) {
if (mq_fevts_map.contains(wrk_index)) {
return;
}
mq_fevts_map[wrk_index] = dispatcher.createFileEvent(
Expand Down
2 changes: 1 addition & 1 deletion source/common/access_log/access_log_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool GrpcStatusFilter::evaluate(const Formatter::Context& context,
status = optional_status.value();
}

const bool found = statuses_.find(status) != statuses_.end();
const bool found = statuses_.contains(status);
return exclude_ ? !found : found;
}

Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/win32/watcher_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ absl::Status WatcherImpl::addWatch(absl::string_view path, uint32_t events, OnCh
RELEASE_ASSERT(
GetFileInformationByHandleEx(dir_handle, FileIdInfo, &fii_key[0], sizeof(FILE_ID_INFO)),
fmt::format("unable to identify directory {}: {}", result.directory_, GetLastError()));
if (callback_map_.find(fii_key) != callback_map_.end()) {
if (callback_map_.contains(fii_key)) {
CloseHandle(dir_handle);
} else {
callback_map_[fii_key] = std::make_unique<DirectoryWatch>();
Expand Down
2 changes: 1 addition & 1 deletion source/common/grpc/async_client_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ AsyncClientManagerImpl::RawAsyncClientCache::RawAsyncClientCache(
void AsyncClientManagerImpl::RawAsyncClientCache::setCache(
const GrpcServiceConfigWithHashKey& config_with_hash_key,
const RawAsyncClientSharedPtr& client) {
ASSERT(lru_map_.find(config_with_hash_key) == lru_map_.end());
ASSERT(!lru_map_.contains(config_with_hash_key));
// Create a new cache entry at the beginning of the list.
lru_list_.emplace_front(config_with_hash_key, client, dispatcher_.timeSource().monotonicTime());
lru_map_[config_with_hash_key] = lru_list_.begin();
Expand Down
2 changes: 1 addition & 1 deletion source/common/grpc/buffered_async_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ template <class RequestType, class ResponseType> class BufferedAsyncClient {
void erasePendingMessage(uint64_t message_id) {
// This case will be considered if `onSuccess` had called with unknown message id that is not
// received by envoy as response.
if (message_buffer_.find(message_id) == message_buffer_.end()) {
if (!message_buffer_.contains(message_id)) {
return;
}
auto& buffer = message_buffer_.at(message_id);
Expand Down
2 changes: 1 addition & 1 deletion source/common/grpc/google_async_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GoogleAsyncClientThreadLocal : public ThreadLocal::ThreadLocalObject,
grpc::CompletionQueue& completionQueue() { return cq_; }

void registerStream(GoogleAsyncStreamImpl* stream) {
ASSERT(streams_.find(stream) == streams_.end());
ASSERT(!streams_.contains(stream));
streams_.insert(stream);
}

Expand Down
2 changes: 1 addition & 1 deletion source/common/http/async_client_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AsyncClientRequestTracker::~AsyncClientRequestTracker() {
}

void AsyncClientRequestTracker::add(AsyncClient::Request& request) {
ASSERT(active_requests_.find(&request) == active_requests_.end(), "request is already tracked.");
ASSERT(!active_requests_.contains(&request), "request is already tracked.");
active_requests_.insert(&request);
}

Expand Down
2 changes: 1 addition & 1 deletion source/common/http/session_idle_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ absl::Duration SessionIdleList::MinTimeBeforeTerminationAllowed() const {

void SessionIdleList::IdleSessions::AddSessionToList(MonotonicTime enqueue_time,
IdleSessionInterface& session) {
if (map_.find(&session) != map_.end()) {
if (map_.contains(&session)) {
IS_ENVOY_BUG("Session is already on the idle list.");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions source/common/http/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ std::string Utility::PercentEncoding::encode(absl::string_view value,
// We do checking for each char in the string. If the current char is included in the defined
// escaping characters, we jump to "the slow path" (append the char [encoded or not encoded]
// to the returned string one by one) started from the current index.
if (ch < ' ' || ch >= '~' || reserved_char_set.find(ch) != reserved_char_set.end()) {
if (ch < ' ' || ch >= '~' || reserved_char_set.contains(ch)) {
return PercentEncoding::encode(value, i, reserved_char_set);
}
}
Expand All @@ -1265,7 +1265,7 @@ std::string Utility::PercentEncoding::encode(absl::string_view value, const size

for (size_t i = index; i < value.size(); ++i) {
const char& ch = value[i];
if (ch < ' ' || ch >= '~' || reserved_char_set.find(ch) != reserved_char_set.end()) {
if (ch < ' ' || ch >= '~' || reserved_char_set.contains(ch)) {
// For consistency, URI producers should use uppercase hexadecimal digits for all
// percent-encodings. https://tools.ietf.org/html/rfc3986#section-2.1.
absl::StrAppend(&encoded, fmt::format("%{:02X}", static_cast<const unsigned char&>(ch)));
Expand Down
2 changes: 1 addition & 1 deletion source/common/init/manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void ManagerImpl::onTargetReady(absl::string_view target_name) {
fmt::format("{} called back by target after initialization complete", target_name));

// Decrease target_name count by 1.
ASSERT(target_names_count_.find(target_name) != target_names_count_.end());
ASSERT(target_names_count_.contains(target_name));
if (--target_names_count_[target_name] == 0) {
target_names_count_.erase(target_name);
}
Expand Down
6 changes: 3 additions & 3 deletions source/common/json/json_rpc_field_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,14 @@ void JsonRpcFieldExtractor::checkEarlyStop() {
if (is_notification_ && field == "id") {
continue;
}
if (collected_fields_.count(field) == 0) {
if (!collected_fields_.contains(field)) {
return;
}
}

const auto& required_fields = config_.getFieldsForMethod(method_);
for (const auto& field : required_fields) {
if (collected_fields_.count(field.path) == 0) {
if (!collected_fields_.contains(field.path)) {
return;
}
}
Expand Down Expand Up @@ -451,7 +451,7 @@ void JsonRpcFieldExtractor::copyFieldByPath(const std::string& path) {
void JsonRpcFieldExtractor::validateRequiredFields() {
const auto& fields = config_.getFieldsForMethod(method_);
for (const auto& field : fields) {
if (extracted_fields_.count(field.path) == 0) {
if (!extracted_fields_.contains(field.path)) {
missing_required_fields_.push_back(field.path);
ENVOY_LOG(debug, "missing required field for {}: {}", method_, field.path);
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/jwt/jwt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool isImplemented(absl::string_view alg) {
{"RS384"}, {"RS512"}, {"PS256"}, {"PS384"}, {"PS512"}, {"EdDSA"},
};

return implemented_algs.find(alg) != implemented_algs.end();
return implemented_algs.contains(alg);
}

} // namespace
Expand Down
4 changes: 2 additions & 2 deletions source/common/listener_manager/filter_chain_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ absl::Status FilterChainManagerImpl::addFilterChains(
const auto* origin = getOriginFilterChainManager();
if (origin != nullptr) {
for (const auto& message_and_filter_chain : origin->fc_contexts_) {
if (fc_contexts_.find(message_and_filter_chain.first) == fc_contexts_.end()) {
if (!fc_contexts_.contains(message_and_filter_chain.first)) {
origin->draining_filter_chains_.push_back(message_and_filter_chain.second);
}
}
Expand Down Expand Up @@ -415,7 +415,7 @@ absl::Status FilterChainManagerImpl::addFilterChainForDestinationPorts(
const std::vector<std::string>& source_ips,
const absl::Span<const Protobuf::uint32> source_ports,
const Network::FilterChainSharedPtr& filter_chain) {
if (destination_ports_map.find(destination_port) == destination_ports_map.end()) {
if (!destination_ports_map.contains(destination_port)) {
destination_ports_map[destination_port] =
std::make_pair<DestinationIPsMap, DestinationIPsTriePtr>(DestinationIPsMap{}, nullptr);
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/listener_manager/listener_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ void ListenerManagerImpl::stopListeners(StopListenersType stop_listeners_type,
// This prevents us from double incrementing if listeners are stopped twice.
// This can happen if the admin endpoint is triggered for inbound_only and then
// all. We perform the check in the callback to ensure it's done on the main thread
if (stopped_listener_tags_.find(listener_tag) == stopped_listener_tags_.end()) {
if (!stopped_listener_tags_.contains(listener_tag)) {
stats_.listener_stopped_.inc();
stopped_listener_tags_.insert(listener_tag);
for (auto& listener : active_listeners_) {
Expand Down
2 changes: 1 addition & 1 deletion source/common/quic/envoy_quic_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void EnvoyQuicDispatcher::closeConnectionsWithFilterChain(
// from the map as well.
connection.close(Network::ConnectionCloseType::NoFlush);
}
ASSERT(connections_by_filter_chain_.find(filter_chain) == connections_by_filter_chain_.end());
ASSERT(!connections_by_filter_chain_.contains(filter_chain));
if (num_connections > 0) {
// Explicitly destroy closed sessions in the current call stack. Because upon
// returning the filter chain configs will be destroyed, and no longer safe to be accessed.
Expand Down
4 changes: 2 additions & 2 deletions source/common/runtime/runtime_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ absl::Status ProtoLayer::walkProtoValue(const Protobuf::Value& v, const std::str
break;
case Protobuf::Value::kStructValue: {
const Protobuf::Struct& s = v.struct_value();
if (s.fields().empty() || s.fields().find("numerator") != s.fields().end() ||
s.fields().find("denominator") != s.fields().end()) {
if (s.fields().empty() || s.fields().contains("numerator") ||
s.fields().contains("denominator")) {
SnapshotImpl::addEntry(values_, prefix, v, "");
break;
}
Expand Down
12 changes: 6 additions & 6 deletions source/common/stats/allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ class TextReadoutImpl : public StatsSharedImpl<TextReadout> {
CounterSharedPtr Allocator::makeCounter(StatName name, StatName tag_extracted_name,
StatNameTagSpan stat_name_tags) {
Thread::LockGuard lock(mutex_);
ASSERT(gauges_.find(name) == gauges_.end());
ASSERT(text_readouts_.find(name) == text_readouts_.end());
ASSERT(!gauges_.contains(name));
ASSERT(!text_readouts_.contains(name));
auto iter = counters_.find(name);
if (iter != counters_.end()) {
return {*iter};
Expand All @@ -316,8 +316,8 @@ CounterSharedPtr Allocator::makeCounter(StatName name, StatName tag_extracted_na
GaugeSharedPtr Allocator::makeGauge(StatName name, StatName tag_extracted_name,
StatNameTagSpan stat_name_tags, Gauge::ImportMode import_mode) {
Thread::LockGuard lock(mutex_);
ASSERT(counters_.find(name) == counters_.end());
ASSERT(text_readouts_.find(name) == text_readouts_.end());
ASSERT(!counters_.contains(name));
ASSERT(!text_readouts_.contains(name));
auto iter = gauges_.find(name);
if (iter != gauges_.end()) {
return {*iter};
Expand All @@ -336,8 +336,8 @@ GaugeSharedPtr Allocator::makeGauge(StatName name, StatName tag_extracted_name,
TextReadoutSharedPtr Allocator::makeTextReadout(StatName name, StatName tag_extracted_name,
StatNameTagSpan stat_name_tags) {
Thread::LockGuard lock(mutex_);
ASSERT(counters_.find(name) == counters_.end());
ASSERT(gauges_.find(name) == gauges_.end());
ASSERT(!counters_.contains(name));
ASSERT(!gauges_.contains(name));
auto iter = text_readouts_.find(name);
if (iter != text_readouts_.end()) {
return {*iter};
Expand Down
2 changes: 1 addition & 1 deletion source/common/stats/custom_stat_namespaces_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Stats {

bool CustomStatNamespacesImpl::registered(const absl::string_view name) const {
ASSERT_IS_MAIN_OR_TEST_THREAD();
return namespaces_.find(name) != namespaces_.end();
return namespaces_.contains(name);
}

void CustomStatNamespacesImpl::registerStatNamespace(const absl::string_view name) {
Expand Down
2 changes: 1 addition & 1 deletion source/common/tcp_proxy/tcp_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ UpstreamDrainManager::~UpstreamDrainManager() {

// cancelDrain() should cause that drainer to be removed from drainers_.
// ASSERT so that we don't end up in an infinite loop.
ASSERT(drainers_.find(key) == drainers_.end());
ASSERT(!drainers_.contains(key));
}

// This destructor is run when shutting down `ThreadLocal`. The destructor of some objects use
Expand Down
4 changes: 2 additions & 2 deletions source/common/upstream/cluster_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ void ClusterManagerImpl::ThreadLocalClusterManagerImpl::removeHosts(
parent_.deferred_cluster_creation_,
fmt::format("Cannot find ThreadLocalCluster {}, but deferred cluster creation is disabled.",
name));
ASSERT(thread_local_deferred_clusters_.find(name) != thread_local_deferred_clusters_.end(),
ASSERT(thread_local_deferred_clusters_.contains(name),
"Cluster with removed host is neither deferred or inflated!");
return;
}
Expand All @@ -1957,7 +1957,7 @@ void ClusterManagerImpl::ThreadLocalClusterManagerImpl::updateClusterMembership(
LocalityWeightsConstSharedPtr locality_weights, const HostVector& hosts_added,
const HostVector& hosts_removed, bool weighted_priority_health,
uint64_t overprovisioning_factor, HostMapConstSharedPtr cross_priority_host_map) {
ASSERT(thread_local_clusters_.find(name) != thread_local_clusters_.end());
ASSERT(thread_local_clusters_.contains(name));
const auto& cluster_entry = thread_local_clusters_[name];
cluster_entry->updateHosts(name, priority, std::move(update_hosts_params),
std::move(locality_weights), hosts_added, hosts_removed,
Expand Down
6 changes: 3 additions & 3 deletions source/common/upstream/outlier_detection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void DetectorImpl::initialize(Cluster& cluster) {
}

void DetectorImpl::addHostMonitor(HostSharedPtr host) {
ASSERT(host_monitors_.count(host) == 0);
ASSERT(!host_monitors_.contains(host));
DetectorHostMonitorImpl* monitor = new DetectorHostMonitorImpl(shared_from_this(), host);
host_monitors_[host] = monitor;
host->setOutlierDetector(DetectorHostMonitorPtr{monitor});
Expand Down Expand Up @@ -663,7 +663,7 @@ void DetectorImpl::setHostDegradedMainThread(HostSharedPtr host) {
// posting this degrade event and the main thread running it; if so, ignore it
// (mirrors the guard in the eject path) so host_monitors_[host] does not
// default-insert a null monitor that is then dereferenced.
if (host_monitors_.count(host) == 0) {
if (!host_monitors_.contains(host)) {
return;
}
if (!host->healthFlagGet(Host::HealthFlag::DEGRADED_OUTLIER_DETECTION)) {
Expand Down Expand Up @@ -704,7 +704,7 @@ void DetectorImpl::onConsecutiveErrorWorker(HostSharedPtr host,
envoy::data::cluster::v3::OutlierEjectionType type) {
// Ejections come in cross thread. There is a chance that the host has already been removed from
// the set. If so, just ignore it.
if (host_monitors_.count(host) == 0) {
if (!host_monitors_.contains(host)) {
return;
}
if (host->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)) {
Expand Down
Loading
Loading