Change robin_hood maps to std::unordered_map

This commit is contained in:
aristocratos 2024-01-02 15:37:36 +01:00
parent 934a9e3cf2
commit 4637ed3991

View file

@ -104,7 +104,7 @@ namespace Cpu {
string cpu_sensor; string cpu_sensor;
vector<string> core_sensors; vector<string> core_sensors;
unordered_flat_map<int, int> core_mapping; std::unordered_map<int, int> core_mapping;
} // namespace Cpu } // namespace Cpu
namespace Mem { namespace Mem {
@ -206,7 +206,7 @@ namespace Cpu {
const array<string, 10> time_names = {"user", "nice", "system", "idle"}; const array<string, 10> time_names = {"user", "nice", "system", "idle"};
unordered_flat_map<string, long long> cpu_old = { std::unordered_map<string, long long> cpu_old = {
{"totals", 0}, {"totals", 0},
{"idles", 0}, {"idles", 0},
{"user", 0}, {"user", 0},
@ -342,8 +342,8 @@ namespace Cpu {
return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz
} }
auto get_core_mapping() -> unordered_flat_map<int, int> { auto get_core_mapping() -> std::unordered_map<int, int> {
unordered_flat_map<int, int> core_map; std::unordered_map<int, int> core_map;
if (cpu_temp_only) return core_map; if (cpu_temp_only) return core_map;
for (long i = 0; i < Shared::coreCount; i++) { 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) { if (getloadavg(cpu.load_avg.data(), cpu.load_avg.size()) < 0) {
Logger::error("failed to get load averages"); Logger::error("failed to get load averages");
} }
auto cp_time = std::unique_ptr<struct cpustats[]>{ auto cp_time = std::unique_ptr<struct cpustats[]>{
new struct cpustats[Shared::coreCount] 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(); while (cmp_greater(disk.io_activity.size(), width * 2)) disk.io_activity.pop_front();
} }
void collect_disk(unordered_flat_map<string, disk_info> &disks, unordered_flat_map<string, string> &mapping) { void collect_disk(std::unordered_map<string, disk_info> &disks, std::unordered_map<string, string> &mapping) {
uint64_t total_bytes_read = 0; uint64_t total_bytes_read = 0;
uint64_t total_bytes_write = 0; uint64_t total_bytes_write = 0;
@ -654,7 +654,7 @@ namespace Mem {
} }
if (show_disks) { if (show_disks) {
unordered_flat_map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint std::unordered_map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
double uptime = system_uptime(); double uptime = system_uptime();
auto &disks_filter = Config::getS("disks_filter"); auto &disks_filter = Config::getS("disks_filter");
bool filter_exclude = false; bool filter_exclude = false;
@ -770,13 +770,13 @@ namespace Mem {
} // namespace Mem } // namespace Mem
namespace Net { namespace Net {
unordered_flat_map<string, net_info> current_net; std::unordered_map<string, net_info> current_net;
net_info empty_net = {}; net_info empty_net = {};
vector<string> interfaces; vector<string> interfaces;
string selected_iface; string selected_iface;
int errors = 0; int errors = 0;
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}}; std::unordered_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}}; std::unordered_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
bool rescale = true; bool rescale = true;
uint64_t timestamp = 0; uint64_t timestamp = 0;
@ -855,7 +855,7 @@ namespace Net {
} //else, ignoring family==AF_LINK (see man 3 getifaddrs) } //else, ignoring family==AF_LINK (see man 3 getifaddrs)
} }
unordered_flat_map<string, std::tuple<uint64_t, uint64_t>> ifstats; std::unordered_map<string, std::tuple<uint64_t, uint64_t>> ifstats;
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0}; int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
size_t len; size_t len;
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) { if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
@ -929,7 +929,6 @@ namespace Net {
else else
it++; it++;
} }
net.compact();
} }
timestamp = new_timestamp; timestamp = new_timestamp;
@ -1000,7 +999,7 @@ namespace Net {
namespace Proc { namespace Proc {
vector<proc_info> current_procs; vector<proc_info> current_procs;
unordered_flat_map<string, string> uid_user; std::unordered_map<string, string> uid_user;
string current_sort; string current_sort;
string current_filter; string current_filter;
bool current_rev = false; bool current_rev = false;