perf: avoid redundant map lookup in HidChooserContext::DeviceChanged() (#46451)

perf: avoid redundant map lookup in HidChooserContext::DeviceChanged()
This commit is contained in:
Charles Kerr 2025-04-03 17:51:37 -05:00 committed by GitHub
parent 7601af5200
commit 0a5da83a1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -274,10 +274,11 @@ void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
void HidChooserContext::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {
DCHECK(device);
DCHECK(devices_.contains(device->guid));
// Update the device list.
devices_[device->guid] = device->Clone();
auto& mapped = devices_[device->guid];
DCHECK(!mapped.is_null());
mapped = device->Clone();
// Notify all observers.
for (auto& observer : device_observer_list_)