perf: don't build unused vectors in HidChooserContext (#43212)
* refactor: remove unused code in HidChooserContext::DeviceRemoved() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: remove unused code in HidChooserContext::OnHidManagerConnectionError() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use structured bindings for readability Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
53a6765fd6
commit
a1342720ec
1 changed files with 2 additions and 12 deletions
|
@ -276,13 +276,8 @@ void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
|
||||||
if (CanStorePersistentEntry(*device))
|
if (CanStorePersistentEntry(*device))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<url::Origin> revoked_origins;
|
for (auto& [origin, guids] : ephemeral_devices_)
|
||||||
for (auto& map_entry : ephemeral_devices_) {
|
guids.erase(device->guid);
|
||||||
if (map_entry.second.erase(device->guid) > 0)
|
|
||||||
revoked_origins.push_back(map_entry.first);
|
|
||||||
}
|
|
||||||
if (revoked_origins.empty())
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HidChooserContext::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {
|
void HidChooserContext::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {
|
||||||
|
@ -341,11 +336,6 @@ void HidChooserContext::OnHidManagerConnectionError() {
|
||||||
hid_manager_.reset();
|
hid_manager_.reset();
|
||||||
client_receiver_.reset();
|
client_receiver_.reset();
|
||||||
devices_.clear();
|
devices_.clear();
|
||||||
|
|
||||||
std::vector<url::Origin> revoked_origins;
|
|
||||||
revoked_origins.reserve(ephemeral_devices_.size());
|
|
||||||
for (const auto& map_entry : ephemeral_devices_)
|
|
||||||
revoked_origins.push_back(map_entry.first);
|
|
||||||
ephemeral_devices_.clear();
|
ephemeral_devices_.clear();
|
||||||
|
|
||||||
// Notify all device observers.
|
// Notify all device observers.
|
||||||
|
|
Loading…
Reference in a new issue