refactor: use C++20's contains() method (#45742)

* chore: use std::map<>::contains() instead of count() or find()

* chore: use std::map<>::contains() instead of base::Contains()
This commit is contained in:
Charles Kerr 2025-02-21 17:33:43 -06:00 committed by GitHub
parent 612da3ec47
commit 2a383e9ddd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 54 additions and 77 deletions

View file

@ -9,7 +9,6 @@
#include <utility>
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/values.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/web_contents.h"
@ -108,7 +107,7 @@ bool SerialChooserContext::HasPortPermission(
auto it = ephemeral_ports_.find(origin);
if (it != ephemeral_ports_.end()) {
const std::set<base::UnguessableToken>& ports = it->second;
if (base::Contains(ports, port.token))
if (ports.contains(port.token))
return true;
}
@ -226,7 +225,7 @@ base::WeakPtr<SerialChooserContext> SerialChooserContext::AsWeakPtr() {
}
void SerialChooserContext::OnPortAdded(device::mojom::SerialPortInfoPtr port) {
if (!base::Contains(port_info_, port->token))
if (!port_info_.contains(port->token))
port_info_.insert({port->token, port->Clone()});
for (auto& map_entry : ephemeral_ports_) {