perf: avoid triple map lookup in ElectronHidDelegate::GetContextObserver() (#46672)

perf: avoid triple map lookup in ElectronHidDelegate::GetContextObserver()
This commit is contained in:
Charles Kerr 2025-04-19 10:51:52 -05:00 committed by GitHub
parent 3a982ecad5
commit 297c4297b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -221,11 +221,10 @@ bool ElectronHidDelegate::IsServiceWorkerAllowedForOrigin(
ElectronHidDelegate::ContextObservation*
ElectronHidDelegate::GetContextObserver(
content::BrowserContext* browser_context) {
if (!observations_.contains(browser_context)) {
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
this, browser_context));
}
return observations_[browser_context].get();
auto& observation = observations_[browser_context];
if (!observation)
observation = std::make_unique<ContextObservation>(this, browser_context);
return observation.get();
}
HidChooserController* ElectronHidDelegate::ControllerForFrame(