perf: avoid double map lookup in HidChooserContext::DeviceRemoved() (#46360)

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:
trop[bot]
2025-03-29 08:12:22 -05:00
committed by GitHub
parent b4568e63aa
commit b4540e013d

View File

@@ -256,10 +256,10 @@ void HidChooserContext::DeviceAdded(device::mojom::HidDeviceInfoPtr device) {
void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
DCHECK(device);
DCHECK(devices_.contains(device->guid));
// Update the device list.
devices_.erase(device->guid);
const size_t n_erased = devices_.erase(device->guid);
DCHECK_EQ(n_erased, 1U);
// Notify all device observers.
for (auto& observer : device_observer_list_)