perf: use absl::flat_hash_map instead of std::unordered_map (#46217)

* perf: make ElectronUsbDelegate::controller_map_ an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make ElectronSerialDelegate::controller_map_ an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make ElectronHidDelegate::controller_map_ an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make FrameTreeNodeIdMap an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make AutofillDriverFactory::driver_map_ an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make asar::Archive::external_files_ an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make VersionIdMap an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: make ObjectCache::proxy_map_ an absl::flat_hash_map

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* docs: add TODO to investigate absl map in KeyWeakMap

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:
trop[bot] 2025-03-24 09:30:52 -05:00 committed by GitHub
parent e1b2b8ef0c
commit 76fa5b7af1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 24 additions and 24 deletions

View file

@ -7,7 +7,6 @@
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "base/containers/span.h"
@ -17,6 +16,7 @@
#include "services/device/public/mojom/usb_device.mojom-forward.h"
#include "services/device/public/mojom/usb_enumeration_options.mojom-forward.h"
#include "services/device/public/mojom/usb_manager.mojom-forward.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
#include "third_party/blink/public/mojom/usb/web_usb_service.mojom.h"
#include "url/origin.h"
@ -111,8 +111,8 @@ class ElectronUsbDelegate : public content::UsbDelegate {
base::flat_map<content::BrowserContext*, std::unique_ptr<ContextObservation>>
observations_;
std::unordered_map<content::RenderFrameHost*,
std::unique_ptr<UsbChooserController>>
absl::flat_hash_map<content::RenderFrameHost*,
std::unique_ptr<UsbChooserController>>
controller_map_;
base::WeakPtrFactory<ElectronUsbDelegate> weak_factory_{this};