refactor: use std::map::try_emplace()
over std::map::insert()
(#46761)
refactor: prefer std::map::try_emplace() over std::map::insert()
This commit is contained in:
parent
8fa7d324d1
commit
b40b4dc015
10 changed files with 15 additions and 21 deletions
|
@ -87,7 +87,7 @@ void SerialChooserContext::GrantPortPermission(
|
|||
const url::Origin& origin,
|
||||
const device::mojom::SerialPortInfo& port,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
port_info_.insert({port.token, port.Clone()});
|
||||
port_info_.try_emplace(port.token, port.Clone());
|
||||
|
||||
if (CanStorePersistentEntry(port)) {
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
|
@ -275,7 +275,7 @@ void SerialChooserContext::SetUpPortManagerConnection(
|
|||
void SerialChooserContext::OnGetDevices(
|
||||
std::vector<device::mojom::SerialPortInfoPtr> ports) {
|
||||
for (auto& port : ports)
|
||||
port_info_.insert({port->token, std::move(port)});
|
||||
port_info_.try_emplace(port->token, std::move(port));
|
||||
is_initialized_ = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue