From 76fa5b7af1df4544eced433f764ecf250be532b3 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 09:30:52 -0500 Subject: [PATCH] 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 * perf: make ElectronSerialDelegate::controller_map_ an absl::flat_hash_map Co-authored-by: Charles Kerr * perf: make ElectronHidDelegate::controller_map_ an absl::flat_hash_map Co-authored-by: Charles Kerr * perf: make FrameTreeNodeIdMap an absl::flat_hash_map Co-authored-by: Charles Kerr * perf: make AutofillDriverFactory::driver_map_ an absl::flat_hash_map Co-authored-by: Charles Kerr * perf: make asar::Archive::external_files_ an absl::flat_hash_map Co-authored-by: Charles Kerr * perf: make VersionIdMap an absl::flat_hash_map Co-authored-by: Charles Kerr * perf: make ObjectCache::proxy_map_ an absl::flat_hash_map Co-authored-by: Charles Kerr * docs: add TODO to investigate absl map in KeyWeakMap Co-authored-by: Charles Kerr --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/api/electron_api_service_worker_main.cc | 9 ++++----- shell/browser/api/electron_api_web_frame_main.cc | 4 ++-- shell/browser/electron_autofill_driver_factory.h | 5 +++-- shell/browser/hid/electron_hid_delegate.h | 6 +++--- shell/browser/serial/electron_serial_delegate.h | 6 +++--- shell/browser/usb/electron_usb_delegate.h | 6 +++--- shell/common/asar/archive.h | 6 +++--- shell/common/key_weak_map.h | 1 + shell/renderer/api/context_bridge/object_cache.h | 5 ++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/shell/browser/api/electron_api_service_worker_main.cc b/shell/browser/api/electron_api_service_worker_main.cc index 4d06cc083a12..5d3482f3e1b7 100644 --- a/shell/browser/api/electron_api_service_worker_main.cc +++ b/shell/browser/api/electron_api_service_worker_main.cc @@ -5,7 +5,6 @@ #include "shell/browser/api/electron_api_service_worker_main.h" #include -#include #include #include "base/logging.h" @@ -28,6 +27,7 @@ #include "shell/common/gin_helper/promise.h" #include "shell/common/node_includes.h" #include "shell/common/v8_util.h" +#include "third_party/abseil-cpp/absl/container/flat_hash_map.h" namespace { @@ -58,10 +58,9 @@ std::optional GetLiveVersionInfo( namespace electron::api { // ServiceWorkerKey -> ServiceWorkerMain* -typedef std::unordered_map - VersionIdMap; +using VersionIdMap = absl::flat_hash_map; VersionIdMap& GetVersionIdMap() { static base::NoDestructor instance; diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index 40e3d811baf8..2cc7a1b47c0f 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -5,7 +5,6 @@ #include "shell/browser/api/electron_api_web_frame_main.h" #include -#include #include #include @@ -36,6 +35,7 @@ #include "shell/common/gin_helper/promise.h" #include "shell/common/node_includes.h" #include "shell/common/v8_util.h" +#include "third_party/abseil-cpp/absl/container/flat_hash_map.h" namespace { @@ -99,7 +99,7 @@ namespace electron::api { // Using FrameTreeNode allows us to track frame across navigations. This // is most similar to how