From 4637ed399134083e429fd63a002b897d9f2cb5ee Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 2 Jan 2024 15:37:36 +0100 Subject: [PATCH] Change robin_hood maps to std::unordered_map --- src/openbsd/btop_collect.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/openbsd/btop_collect.cpp b/src/openbsd/btop_collect.cpp index 1d4e774..df35662 100644 --- a/src/openbsd/btop_collect.cpp +++ b/src/openbsd/btop_collect.cpp @@ -104,7 +104,7 @@ namespace Cpu { string cpu_sensor; vector core_sensors; - unordered_flat_map core_mapping; + std::unordered_map core_mapping; } // namespace Cpu namespace Mem { @@ -206,7 +206,7 @@ namespace Cpu { const array time_names = {"user", "nice", "system", "idle"}; - unordered_flat_map cpu_old = { + std::unordered_map cpu_old = { {"totals", 0}, {"idles", 0}, {"user", 0}, @@ -342,8 +342,8 @@ namespace Cpu { return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz } - auto get_core_mapping() -> unordered_flat_map { - unordered_flat_map core_map; + auto get_core_mapping() -> std::unordered_map { + std::unordered_map core_map; if (cpu_temp_only) return core_map; for (long i = 0; i < Shared::coreCount; i++) { @@ -428,7 +428,7 @@ namespace Cpu { if (getloadavg(cpu.load_avg.data(), cpu.load_avg.size()) < 0) { Logger::error("failed to get load averages"); } - + auto cp_time = std::unique_ptr{ new struct cpustats[Shared::coreCount] }; @@ -560,7 +560,7 @@ namespace Mem { while (cmp_greater(disk.io_activity.size(), width * 2)) disk.io_activity.pop_front(); } - void collect_disk(unordered_flat_map &disks, unordered_flat_map &mapping) { + void collect_disk(std::unordered_map &disks, std::unordered_map &mapping) { uint64_t total_bytes_read = 0; uint64_t total_bytes_write = 0; @@ -654,7 +654,7 @@ namespace Mem { } if (show_disks) { - unordered_flat_map mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint + std::unordered_map mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint double uptime = system_uptime(); auto &disks_filter = Config::getS("disks_filter"); bool filter_exclude = false; @@ -770,13 +770,13 @@ namespace Mem { } // namespace Mem namespace Net { - unordered_flat_map current_net; + std::unordered_map current_net; net_info empty_net = {}; vector interfaces; string selected_iface; int errors = 0; - unordered_flat_map graph_max = {{"download", {}}, {"upload", {}}}; - unordered_flat_map> max_count = {{"download", {}}, {"upload", {}}}; + std::unordered_map graph_max = {{"download", {}}, {"upload", {}}}; + std::unordered_map> max_count = {{"download", {}}, {"upload", {}}}; bool rescale = true; uint64_t timestamp = 0; @@ -855,7 +855,7 @@ namespace Net { } //else, ignoring family==AF_LINK (see man 3 getifaddrs) } - unordered_flat_map> ifstats; + std::unordered_map> ifstats; int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0}; size_t len; if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) { @@ -929,7 +929,6 @@ namespace Net { else it++; } - net.compact(); } timestamp = new_timestamp; @@ -1000,7 +999,7 @@ namespace Net { namespace Proc { vector current_procs; - unordered_flat_map uid_user; + std::unordered_map uid_user; string current_sort; string current_filter; bool current_rev = false;