mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-17 09:54:57 +12:00
Remove robin-hood-hashing dependency
As per https://github.com/aristocratos/btop/pull/617 using a specialized hash map/set is not worth the effort
This commit is contained in:
parent
2c3ac4855d
commit
4fe5b4bcb3
2544
include/robin_hood.h
2544
include/robin_hood.h
File diff suppressed because it is too large
Load diff
|
@ -32,6 +32,8 @@ tab-size = 4
|
|||
#include <tuple>
|
||||
#include <regex>
|
||||
#include <chrono>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#ifdef __APPLE__
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
@ -398,7 +400,7 @@ namespace Runner {
|
|||
};
|
||||
|
||||
string debug_bg;
|
||||
unordered_flat_map<string, array<uint64_t, 2>> debug_times;
|
||||
std::unordered_map<string, array<uint64_t, 2>> debug_times;
|
||||
|
||||
class MyNumPunct : public std::numpunct<char>
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ tab-size = 4
|
|||
#include <fstream>
|
||||
#include <ranges>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
|
@ -195,7 +196,7 @@ namespace Config {
|
|||
"#* The level set includes all lower levels, i.e. \"DEBUG\" will show all logging info."}
|
||||
};
|
||||
|
||||
unordered_flat_map<std::string_view, string> strings = {
|
||||
std::unordered_map<std::string_view, string> strings = {
|
||||
{"color_theme", "Default"},
|
||||
{"shown_boxes", "cpu mem net proc"},
|
||||
{"graph_symbol", "braille"},
|
||||
|
@ -221,9 +222,9 @@ namespace Config {
|
|||
{"proc_command", ""},
|
||||
{"selected_name", ""},
|
||||
};
|
||||
unordered_flat_map<std::string_view, string> stringsTmp;
|
||||
std::unordered_map<std::string_view, string> stringsTmp;
|
||||
|
||||
unordered_flat_map<std::string_view, bool> bools = {
|
||||
std::unordered_map<std::string_view, bool> bools = {
|
||||
{"theme_background", true},
|
||||
{"truecolor", true},
|
||||
{"rounded_corners", true},
|
||||
|
@ -269,9 +270,9 @@ namespace Config {
|
|||
{"show_detailed", false},
|
||||
{"proc_filtering", false},
|
||||
};
|
||||
unordered_flat_map<std::string_view, bool> boolsTmp;
|
||||
std::unordered_map<std::string_view, bool> boolsTmp;
|
||||
|
||||
unordered_flat_map<std::string_view, int> ints = {
|
||||
std::unordered_map<std::string_view, int> ints = {
|
||||
{"update_ms", 2000},
|
||||
{"net_download", 100},
|
||||
{"net_upload", 100},
|
||||
|
@ -282,7 +283,7 @@ namespace Config {
|
|||
{"proc_selected", 0},
|
||||
{"proc_last_selected", 0},
|
||||
};
|
||||
unordered_flat_map<std::string_view, int> intsTmp;
|
||||
std::unordered_map<std::string_view, int> intsTmp;
|
||||
|
||||
bool _locked(const std::string_view name) {
|
||||
atomic_wait(writelock, true);
|
||||
|
|
|
@ -18,15 +18,14 @@ tab-size = 4
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <robin_hood.h>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using robin_hood::unordered_flat_map;
|
||||
|
||||
//* Functions and variables for reading and writing the btop config file
|
||||
namespace Config {
|
||||
|
@ -34,12 +33,12 @@ namespace Config {
|
|||
extern std::filesystem::path conf_dir;
|
||||
extern std::filesystem::path conf_file;
|
||||
|
||||
extern unordered_flat_map<std::string_view, string> strings;
|
||||
extern unordered_flat_map<std::string_view, string> stringsTmp;
|
||||
extern unordered_flat_map<std::string_view, bool> bools;
|
||||
extern unordered_flat_map<std::string_view, bool> boolsTmp;
|
||||
extern unordered_flat_map<std::string_view, int> ints;
|
||||
extern unordered_flat_map<std::string_view, int> intsTmp;
|
||||
extern std::unordered_map<std::string_view, string> strings;
|
||||
extern std::unordered_map<std::string_view, string> stringsTmp;
|
||||
extern std::unordered_map<std::string_view, bool> bools;
|
||||
extern std::unordered_map<std::string_view, bool> boolsTmp;
|
||||
extern std::unordered_map<std::string_view, int> ints;
|
||||
extern std::unordered_map<std::string_view, int> intsTmp;
|
||||
|
||||
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
||||
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
||||
|
|
|
@ -16,10 +16,12 @@ indent = tab
|
|||
tab-size = 4
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <ranges>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "btop_draw.hpp"
|
||||
#include "btop_config.hpp"
|
||||
|
@ -51,7 +53,7 @@ namespace Symbols {
|
|||
|
||||
const array<string, 10> superscript = { "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹" };
|
||||
|
||||
const unordered_flat_map<string, vector<string>> graph_symbols = {
|
||||
const std::unordered_map<string, vector<string>> graph_symbols = {
|
||||
{ "braille_up", {
|
||||
" ", "⢀", "⢠", "⢰", "⢸",
|
||||
"⡀", "⣀", "⣠", "⣰", "⣸",
|
||||
|
@ -297,7 +299,7 @@ namespace Draw {
|
|||
return false;
|
||||
}
|
||||
|
||||
static const unordered_flat_map<string, string> clock_custom_format = {
|
||||
static const std::unordered_map<string, string> clock_custom_format = {
|
||||
{"/user", Tools::username()},
|
||||
{"/host", Tools::hostname()},
|
||||
{"/uptime", ""}
|
||||
|
@ -605,7 +607,7 @@ namespace Cpu {
|
|||
static long old_seconds{}; // defaults to = 0
|
||||
static string old_status;
|
||||
static Draw::Meter bat_meter {10, "cpu", true};
|
||||
static const unordered_flat_map<string, string> bat_symbols = {
|
||||
static const std::unordered_map<string, string> bat_symbols = {
|
||||
{"charging", "▲"},
|
||||
{"discharging", "▼"},
|
||||
{"full", "■"},
|
||||
|
@ -749,11 +751,11 @@ namespace Mem {
|
|||
int disks_io_half = 0;
|
||||
bool shown = true, redraw = true;
|
||||
string box;
|
||||
unordered_flat_map<string, Draw::Meter> mem_meters;
|
||||
unordered_flat_map<string, Draw::Graph> mem_graphs;
|
||||
unordered_flat_map<string, Draw::Meter> disk_meters_used;
|
||||
unordered_flat_map<string, Draw::Meter> disk_meters_free;
|
||||
unordered_flat_map<string, Draw::Graph> io_graphs;
|
||||
std::unordered_map<string, Draw::Meter> mem_meters;
|
||||
std::unordered_map<string, Draw::Graph> mem_graphs;
|
||||
std::unordered_map<string, Draw::Meter> disk_meters_used;
|
||||
std::unordered_map<string, Draw::Meter> disk_meters_free;
|
||||
std::unordered_map<string, Draw::Graph> io_graphs;
|
||||
|
||||
string draw(const mem_info& mem, bool force_redraw, bool data_same) {
|
||||
if (Runner::stopping) return "";
|
||||
|
@ -801,7 +803,7 @@ namespace Mem {
|
|||
//? Disk meters and io graphs
|
||||
if (show_disks) {
|
||||
if (show_io_stat or io_mode) {
|
||||
unordered_flat_map<string, int> custom_speeds;
|
||||
std::unordered_map<string, int> custom_speeds;
|
||||
int half_height = 0;
|
||||
if (io_mode) {
|
||||
disks_io_h = max((int)floor((double)(height - 2 - (disk_ios * 2)) / max(1, disk_ios)), (io_graph_combined ? 1 : 2));
|
||||
|
@ -1006,7 +1008,7 @@ namespace Net {
|
|||
int b_x, b_y, b_width, b_height, d_graph_height, u_graph_height;
|
||||
bool shown = true, redraw = true;
|
||||
string old_ip;
|
||||
unordered_flat_map<string, Draw::Graph> graphs;
|
||||
std::unordered_map<string, Draw::Graph> graphs;
|
||||
string box;
|
||||
|
||||
string draw(const net_info& net, bool force_redraw, bool data_same) {
|
||||
|
@ -1106,9 +1108,9 @@ namespace Proc {
|
|||
bool shown = true, redraw = true;
|
||||
int selected_pid = 0, selected_depth = 0;
|
||||
string selected_name;
|
||||
unordered_flat_map<size_t, Draw::Graph> p_graphs;
|
||||
unordered_flat_map<size_t, bool> p_wide_cmd;
|
||||
unordered_flat_map<size_t, int> p_counters;
|
||||
std::unordered_map<size_t, Draw::Graph> p_graphs;
|
||||
std::unordered_map<size_t, bool> p_wide_cmd;
|
||||
std::unordered_map<size_t, int> p_counters;
|
||||
int counter = 0;
|
||||
Draw::TextEdit filter;
|
||||
Draw::Graph detailed_cpu_graph;
|
||||
|
@ -1566,8 +1568,6 @@ namespace Proc {
|
|||
else
|
||||
++element;
|
||||
}
|
||||
p_graphs.compact();
|
||||
p_counters.compact();
|
||||
|
||||
for (auto element = p_wide_cmd.begin(); element != p_wide_cmd.end();) {
|
||||
if (rng::find(plist, element->first, &proc_info::pid) == plist.end()) {
|
||||
|
@ -1576,7 +1576,6 @@ namespace Proc {
|
|||
else
|
||||
++element;
|
||||
}
|
||||
p_wide_cmd.compact();
|
||||
}
|
||||
|
||||
if (selected == 0 and selected_pid != 0) {
|
||||
|
|
|
@ -18,13 +18,12 @@ tab-size = 4
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <robin_hood.h>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::string;
|
||||
|
@ -108,7 +107,7 @@ namespace Draw {
|
|||
long long offset;
|
||||
long long last = 0, max_value = 0;
|
||||
bool current = true, tty_mode = false;
|
||||
unordered_flat_map<bool, vector<string>> graphs = { {true, {}}, {false, {}}};
|
||||
std::unordered_map<bool, vector<string>> graphs = { {true, {}}, {false, {}}};
|
||||
|
||||
//* Create two representations of the graph to switch between to represent two values for each braille character
|
||||
void _create(const deque<long long>& data, int data_offset);
|
||||
|
@ -135,6 +134,6 @@ namespace Draw {
|
|||
|
||||
namespace Proc {
|
||||
extern Draw::TextEdit filter;
|
||||
extern unordered_flat_map<size_t, Draw::Graph> p_graphs;
|
||||
extern unordered_flat_map<size_t, int> p_counters;
|
||||
extern std::unordered_map<size_t, Draw::Graph> p_graphs;
|
||||
extern std::unordered_map<size_t, int> p_counters;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,14 @@ indent = tab
|
|||
tab-size = 4
|
||||
*/
|
||||
|
||||
#include <csignal>
|
||||
#include <iostream>
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <signal.h>
|
||||
#include <ranges>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "btop_input.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
|
@ -40,7 +42,7 @@ namespace rng = std::ranges;
|
|||
namespace Input {
|
||||
|
||||
//* Map for translating key codes to readable values
|
||||
const unordered_flat_map<string, string> Key_escapes = {
|
||||
const std::unordered_map<string, string> Key_escapes = {
|
||||
{"\033", "escape"},
|
||||
{"\n", "enter"},
|
||||
{" ", "space"},
|
||||
|
@ -79,7 +81,7 @@ namespace Input {
|
|||
std::atomic<bool> interrupt (false);
|
||||
std::atomic<bool> polling (false);
|
||||
array<int, 2> mouse_pos;
|
||||
unordered_flat_map<string, Mouse_loc> mouse_mappings;
|
||||
std::unordered_map<string, Mouse_loc> mouse_mappings;
|
||||
|
||||
deque<string> history(50, "");
|
||||
string old_filter;
|
||||
|
|
|
@ -18,13 +18,12 @@ tab-size = 4
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
#include <robin_hood.h>
|
||||
#include <atomic>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
using std::array;
|
||||
using std::atomic;
|
||||
using std::deque;
|
||||
|
@ -44,7 +43,7 @@ namespace Input {
|
|||
};
|
||||
|
||||
//? line, col, height, width
|
||||
extern unordered_flat_map<string, Mouse_loc> mouse_mappings;
|
||||
extern std::unordered_map<string, Mouse_loc> mouse_mappings;
|
||||
|
||||
extern atomic<bool> interrupt;
|
||||
extern atomic<bool> polling;
|
||||
|
|
|
@ -16,13 +16,12 @@ indent = tab
|
|||
tab-size = 4
|
||||
*/
|
||||
|
||||
#include <deque>
|
||||
#include <robin_hood.h>
|
||||
#include <array>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <csignal>
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "btop_menu.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
|
@ -31,7 +30,6 @@ tab-size = 4
|
|||
#include "btop_draw.hpp"
|
||||
#include "btop_shared.hpp"
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
using std::array;
|
||||
using std::ceil;
|
||||
using std::max;
|
||||
|
@ -65,7 +63,7 @@ namespace Menu {
|
|||
"SIGPWR", "SIGSYS"
|
||||
};
|
||||
|
||||
unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
||||
std::unordered_map<string, Input::Mouse_loc> mouse_mappings;
|
||||
|
||||
const array<array<string, 3>, 3> menu_normal = {
|
||||
array<string, 3>{
|
||||
|
@ -1015,7 +1013,7 @@ namespace Menu {
|
|||
static Draw::TextEdit editor;
|
||||
static string warnings;
|
||||
static bitset<8> selPred;
|
||||
static const unordered_flat_map<string, std::reference_wrapper<const vector<string>>> optionsList = {
|
||||
static const std::unordered_map<string, std::reference_wrapper<const vector<string>>> optionsList = {
|
||||
{"color_theme", std::cref(Theme::themes)},
|
||||
{"log_level", std::cref(Logger::log_levels)},
|
||||
{"temp_scale", std::cref(Config::temp_scales)},
|
||||
|
|
|
@ -18,10 +18,11 @@ tab-size = 4
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "btop_input.hpp"
|
||||
|
||||
|
@ -38,7 +39,7 @@ namespace Menu {
|
|||
extern bool redraw;
|
||||
|
||||
//? line, col, height, width
|
||||
extern unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
||||
extern std::unordered_map<string, Input::Mouse_loc> mouse_mappings;
|
||||
|
||||
//* Creates a message box centered on screen
|
||||
//? Height of box is determined by size of content vector
|
||||
|
|
|
@ -24,12 +24,12 @@ tab-size = 4
|
|||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <ifaddrs.h>
|
||||
#include <robin_hood.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
using std::array;
|
||||
using std::atomic;
|
||||
using std::deque;
|
||||
|
@ -96,7 +96,7 @@ namespace Cpu {
|
|||
extern tuple<int, long, string> current_bat;
|
||||
|
||||
struct cpu_info {
|
||||
unordered_flat_map<string, deque<long long>> cpu_percent = {
|
||||
std::unordered_map<string, deque<long long>> cpu_percent = {
|
||||
{"total", {}},
|
||||
{"user", {}},
|
||||
{"nice", {}},
|
||||
|
@ -122,8 +122,8 @@ namespace Cpu {
|
|||
string draw(const cpu_info& cpu, bool force_redraw = false, bool data_same = false);
|
||||
|
||||
//* Parse /proc/cpu info for mapping of core ids
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int>;
|
||||
extern unordered_flat_map<int, int> core_mapping;
|
||||
auto get_core_mapping() -> std::unordered_map<int, int>;
|
||||
extern std::unordered_map<int, int> core_mapping;
|
||||
|
||||
//* Get battery info from /sys
|
||||
auto get_battery() -> tuple<int, long, string>;
|
||||
|
@ -155,13 +155,13 @@ namespace Mem {
|
|||
};
|
||||
|
||||
struct mem_info {
|
||||
unordered_flat_map<string, uint64_t> stats =
|
||||
std::unordered_map<string, uint64_t> stats =
|
||||
{{"used", 0}, {"available", 0}, {"cached", 0}, {"free", 0},
|
||||
{"swap_total", 0}, {"swap_used", 0}, {"swap_free", 0}};
|
||||
unordered_flat_map<string, deque<long long>> percent =
|
||||
std::unordered_map<string, deque<long long>> percent =
|
||||
{{"used", {}}, {"available", {}}, {"cached", {}}, {"free", {}},
|
||||
{"swap_total", {}}, {"swap_used", {}}, {"swap_free", {}}};
|
||||
unordered_flat_map<string, disk_info> disks;
|
||||
std::unordered_map<string, disk_info> disks;
|
||||
vector<string> disks_order;
|
||||
};
|
||||
|
||||
|
@ -183,7 +183,7 @@ namespace Net {
|
|||
extern string selected_iface;
|
||||
extern vector<string> interfaces;
|
||||
extern bool rescale;
|
||||
extern unordered_flat_map<string, uint64_t> graph_max;
|
||||
extern std::unordered_map<string, uint64_t> graph_max;
|
||||
|
||||
struct net_stat {
|
||||
uint64_t speed{}; // defaults to 0
|
||||
|
@ -195,14 +195,14 @@ namespace Net {
|
|||
};
|
||||
|
||||
struct net_info {
|
||||
unordered_flat_map<string, deque<long long>> bandwidth = { {"download", {}}, {"upload", {}} };
|
||||
unordered_flat_map<string, net_stat> stat = { {"download", {}}, {"upload", {}} };
|
||||
std::unordered_map<string, deque<long long>> bandwidth = { {"download", {}}, {"upload", {}} };
|
||||
std::unordered_map<string, net_stat> stat = { {"download", {}}, {"upload", {}} };
|
||||
string ipv4{}; // defaults to ""
|
||||
string ipv6{}; // defaults to ""
|
||||
bool connected{}; // defaults to false
|
||||
};
|
||||
|
||||
extern unordered_flat_map<string, net_info> current_net;
|
||||
extern std::unordered_map<string, net_info> current_net;
|
||||
|
||||
//* Collect net upload/download stats
|
||||
auto collect(bool no_update=false) -> net_info&;
|
||||
|
@ -235,7 +235,7 @@ namespace Proc {
|
|||
};
|
||||
|
||||
//? Translation from process state char to explanative string
|
||||
const unordered_flat_map<char, string> proc_states = {
|
||||
const std::unordered_map<char, string> proc_states = {
|
||||
{'R', "Running"},
|
||||
{'S', "Sleeping"},
|
||||
{'D', "Waiting"},
|
||||
|
|
|
@ -18,6 +18,8 @@ tab-size = 4
|
|||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "btop_tools.hpp"
|
||||
|
@ -42,11 +44,11 @@ namespace Theme {
|
|||
fs::path theme_dir;
|
||||
fs::path user_theme_dir;
|
||||
vector<string> themes;
|
||||
unordered_flat_map<string, string> colors;
|
||||
unordered_flat_map<string, array<int, 3>> rgbs;
|
||||
unordered_flat_map<string, array<string, 101>> gradients;
|
||||
std::unordered_map<string, string> colors;
|
||||
std::unordered_map<string, array<int, 3>> rgbs;
|
||||
std::unordered_map<string, array<string, 101>> gradients;
|
||||
|
||||
const unordered_flat_map<string, string> Default_theme = {
|
||||
const std::unordered_map<string, string> Default_theme = {
|
||||
{ "main_bg", "#00" },
|
||||
{ "main_fg", "#cc" },
|
||||
{ "title", "#ee" },
|
||||
|
@ -91,7 +93,7 @@ namespace Theme {
|
|||
{ "process_end", "#d45454" }
|
||||
};
|
||||
|
||||
const unordered_flat_map<string, string> TTY_theme = {
|
||||
const std::unordered_map<string, string> TTY_theme = {
|
||||
{ "main_bg", "\x1b[0;40m" },
|
||||
{ "main_fg", "\x1b[37m" },
|
||||
{ "title", "\x1b[97m" },
|
||||
|
@ -224,7 +226,7 @@ namespace Theme {
|
|||
}
|
||||
|
||||
//* Generate colors and rgb decimal vectors for the theme
|
||||
void generateColors(const unordered_flat_map<string, string>& source) {
|
||||
void generateColors(const std::unordered_map<string, string>& source) {
|
||||
vector<string> t_rgb;
|
||||
string depth;
|
||||
bool t_to_256 = Config::getB("lowcolor");
|
||||
|
@ -372,7 +374,7 @@ namespace Theme {
|
|||
|
||||
//* Load a .theme file from disk
|
||||
auto loadFile(const string& filename) {
|
||||
unordered_flat_map<string, string> theme_out;
|
||||
std::unordered_map<string, string> theme_out;
|
||||
const fs::path filepath = filename;
|
||||
if (not fs::exists(filepath))
|
||||
return Default_theme;
|
||||
|
|
|
@ -21,13 +21,12 @@ tab-size = 4
|
|||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <robin_hood.h>
|
||||
|
||||
using std::array;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using robin_hood::unordered_flat_map;
|
||||
|
||||
namespace Theme {
|
||||
extern std::filesystem::path theme_dir;
|
||||
|
@ -54,9 +53,9 @@ namespace Theme {
|
|||
//* Set current theme from current "color_theme" value in config
|
||||
void setTheme();
|
||||
|
||||
extern unordered_flat_map<string, string> colors;
|
||||
extern unordered_flat_map<string, array<int, 3>> rgbs;
|
||||
extern unordered_flat_map<string, array<string, 101>> gradients;
|
||||
extern std::unordered_map<string, string> colors;
|
||||
extern std::unordered_map<string, array<int, 3>> rgbs;
|
||||
extern std::unordered_map<string, array<string, 101>> gradients;
|
||||
|
||||
//* Return escape code for color <name>
|
||||
inline const string& c(const string& name) { return colors.at(name); }
|
||||
|
|
|
@ -30,7 +30,6 @@ tab-size = 4
|
|||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "robin_hood.h"
|
||||
#include "widechar_width.hpp"
|
||||
#include "btop_shared.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
|
@ -43,7 +42,6 @@ using std::flush;
|
|||
using std::max;
|
||||
using std::string_view;
|
||||
using std::to_string;
|
||||
using robin_hood::unordered_flat_map;
|
||||
|
||||
using namespace std::literals; // to use operator""s
|
||||
|
||||
|
|
|
@ -50,14 +50,15 @@ tab-size = 4
|
|||
#include <unistd.h>
|
||||
#include <devstat.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <ranges>
|
||||
#include <regex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "../btop_config.hpp"
|
||||
#include "../btop_shared.hpp"
|
||||
|
@ -98,7 +99,7 @@ namespace Cpu {
|
|||
|
||||
string cpu_sensor;
|
||||
vector<string> core_sensors;
|
||||
unordered_flat_map<int, int> core_mapping;
|
||||
std::unordered_map<int, int> core_mapping;
|
||||
} // namespace Cpu
|
||||
|
||||
namespace Mem {
|
||||
|
@ -204,7 +205,7 @@ namespace Cpu {
|
|||
|
||||
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},
|
||||
{"idles", 0},
|
||||
{"user", 0},
|
||||
|
@ -323,8 +324,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<int, int> {
|
||||
unordered_flat_map<int, int> core_map;
|
||||
auto get_core_mapping() -> std::unordered_map<int, int> {
|
||||
std::unordered_map<int, int> core_map;
|
||||
if (cpu_temp_only) return core_map;
|
||||
|
||||
for (long i = 0; i < Shared::coreCount; i++) {
|
||||
|
@ -557,7 +558,7 @@ namespace Mem {
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
// this bit is for 'regular' mounts
|
||||
static struct statinfo cur;
|
||||
long double etime = 0;
|
||||
|
@ -691,7 +692,7 @@ namespace Mem {
|
|||
}
|
||||
|
||||
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();
|
||||
auto &disks_filter = Config::getS("disks_filter");
|
||||
bool filter_exclude = false;
|
||||
|
@ -807,13 +808,13 @@ namespace Mem {
|
|||
} // namespace Mem
|
||||
|
||||
namespace Net {
|
||||
unordered_flat_map<string, net_info> current_net;
|
||||
std::unordered_map<string, net_info> current_net;
|
||||
net_info empty_net = {};
|
||||
vector<string> interfaces;
|
||||
string selected_iface;
|
||||
int errors = 0;
|
||||
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
std::unordered_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
std::unordered_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
bool rescale = true;
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
|
@ -892,7 +893,7 @@ namespace Net {
|
|||
} //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};
|
||||
size_t len;
|
||||
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
||||
|
@ -966,7 +967,6 @@ namespace Net {
|
|||
else
|
||||
it++;
|
||||
}
|
||||
net.compact();
|
||||
}
|
||||
|
||||
timestamp = new_timestamp;
|
||||
|
@ -1037,7 +1037,7 @@ namespace Net {
|
|||
namespace Proc {
|
||||
|
||||
vector<proc_info> current_procs;
|
||||
unordered_flat_map<string, string> uid_user;
|
||||
std::unordered_map<string, string> uid_user;
|
||||
string current_sort;
|
||||
string current_filter;
|
||||
bool current_rev = false;
|
||||
|
|
|
@ -16,19 +16,22 @@ indent = tab
|
|||
tab-size = 4
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <robin_hood.h>
|
||||
#include <fstream>
|
||||
#include <ranges>
|
||||
#include <cmath>
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <sys/statvfs.h>
|
||||
#include <netdb.h>
|
||||
#include <ranges>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
#include <arpa/inet.h> // for inet_ntop()
|
||||
#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h> // for inet_ntop()
|
||||
#include <filesystem>
|
||||
#include <netdb.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !(defined(STATIC_BUILD) && defined(__GLIBC__))
|
||||
#include <pwd.h>
|
||||
|
@ -83,10 +86,10 @@ namespace Cpu {
|
|||
int64_t crit{}; // defaults to 0
|
||||
};
|
||||
|
||||
unordered_flat_map<string, Sensor> found_sensors;
|
||||
std::unordered_map<string, Sensor> found_sensors;
|
||||
string cpu_sensor;
|
||||
vector<string> core_sensors;
|
||||
unordered_flat_map<int, int> core_mapping;
|
||||
std::unordered_map<int, int> core_mapping;
|
||||
}
|
||||
|
||||
namespace Mem {
|
||||
|
@ -167,7 +170,7 @@ namespace Cpu {
|
|||
"irq"s, "softirq"s, "steal"s, "guest"s, "guest_nice"s
|
||||
};
|
||||
|
||||
unordered_flat_map<string, long long> cpu_old = {
|
||||
std::unordered_map<string, long long> cpu_old = {
|
||||
{"totals", 0},
|
||||
{"idles", 0},
|
||||
{"user", 0},
|
||||
|
@ -464,8 +467,8 @@ namespace Cpu {
|
|||
return cpuhz;
|
||||
}
|
||||
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
||||
unordered_flat_map<int, int> core_map;
|
||||
auto get_core_mapping() -> std::unordered_map<int, int> {
|
||||
std::unordered_map<int, int> core_map;
|
||||
if (cpu_temp_only) return core_map;
|
||||
|
||||
//? Try to get core mapping from /proc/cpuinfo
|
||||
|
@ -538,7 +541,7 @@ namespace Cpu {
|
|||
auto get_battery() -> tuple<int, long, string> {
|
||||
if (not has_battery) return {0, 0, ""};
|
||||
static string auto_sel;
|
||||
static unordered_flat_map<string, battery> batteries;
|
||||
static std::unordered_map<string, battery> batteries;
|
||||
|
||||
//? Get paths to needed files and check for valid values on first run
|
||||
if (batteries.empty() and has_battery) {
|
||||
|
@ -1354,13 +1357,13 @@ namespace Mem {
|
|||
}
|
||||
|
||||
namespace Net {
|
||||
unordered_flat_map<string, net_info> current_net;
|
||||
std::unordered_map<string, net_info> current_net;
|
||||
net_info empty_net = {};
|
||||
vector<string> interfaces;
|
||||
string selected_iface;
|
||||
int errors{}; // defaults to 0
|
||||
unordered_flat_map<string, uint64_t> graph_max = { {"download", {}}, {"upload", {}} };
|
||||
unordered_flat_map<string, array<int, 2>> max_count = { {"download", {}}, {"upload", {}} };
|
||||
std::unordered_map<string, uint64_t> graph_max = { {"download", {}}, {"upload", {}} };
|
||||
std::unordered_map<string, array<int, 2>> max_count = { {"download", {}}, {"upload", {}} };
|
||||
bool rescale{true};
|
||||
uint64_t timestamp{}; // defaults to 0
|
||||
|
||||
|
@ -1499,7 +1502,6 @@ namespace Net {
|
|||
else
|
||||
it++;
|
||||
}
|
||||
net.compact();
|
||||
}
|
||||
|
||||
timestamp = new_timestamp;
|
||||
|
@ -1569,7 +1571,7 @@ namespace Net {
|
|||
namespace Proc {
|
||||
|
||||
vector<proc_info> current_procs;
|
||||
unordered_flat_map<string, string> uid_user;
|
||||
std::unordered_map<string, string> uid_user;
|
||||
string current_sort;
|
||||
string current_filter;
|
||||
bool current_rev{}; // defaults to false
|
||||
|
@ -1584,7 +1586,7 @@ namespace Proc {
|
|||
|
||||
detail_container detailed;
|
||||
constexpr size_t KTHREADD = 2;
|
||||
static robin_hood::unordered_set<size_t> kernels_procs = {KTHREADD};
|
||||
static std::unordered_set<size_t> kernels_procs = {KTHREADD};
|
||||
|
||||
//* Get detailed info for selected process
|
||||
void _collect_details(const size_t pid, const uint64_t uptime, vector<proc_info>& procs) {
|
||||
|
|
|
@ -51,6 +51,8 @@ tab-size = 4
|
|||
#include <ranges>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "../btop_config.hpp"
|
||||
#include "../btop_shared.hpp"
|
||||
|
@ -95,7 +97,7 @@ namespace Cpu {
|
|||
|
||||
string cpu_sensor;
|
||||
vector<string> core_sensors;
|
||||
unordered_flat_map<int, int> core_mapping;
|
||||
std::unordered_map<int, int> core_mapping;
|
||||
} // namespace Cpu
|
||||
|
||||
namespace Mem {
|
||||
|
@ -191,7 +193,7 @@ namespace Cpu {
|
|||
|
||||
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},
|
||||
{"idles", 0},
|
||||
{"user", 0},
|
||||
|
@ -329,8 +331,8 @@ namespace Cpu {
|
|||
return std::to_string(freq / 1000.0 / 1000.0 / 1000.0).substr(0, 3);
|
||||
}
|
||||
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
||||
unordered_flat_map<int, int> core_map;
|
||||
auto get_core_mapping() -> std::unordered_map<int, int> {
|
||||
std::unordered_map<int, int> core_map;
|
||||
if (cpu_temp_only) return core_map;
|
||||
|
||||
natural_t cpu_count;
|
||||
|
@ -591,7 +593,7 @@ namespace Mem {
|
|||
io_object_t &object;
|
||||
};
|
||||
|
||||
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) {
|
||||
io_registry_entry_t drive;
|
||||
io_iterator_t drive_list;
|
||||
|
||||
|
@ -708,7 +710,7 @@ namespace Mem {
|
|||
}
|
||||
|
||||
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();
|
||||
auto &disks_filter = Config::getS("disks_filter");
|
||||
bool filter_exclude = false;
|
||||
|
@ -821,13 +823,13 @@ namespace Mem {
|
|||
} // namespace Mem
|
||||
|
||||
namespace Net {
|
||||
unordered_flat_map<string, net_info> current_net;
|
||||
std::unordered_map<string, net_info> current_net;
|
||||
net_info empty_net = {};
|
||||
vector<string> interfaces;
|
||||
string selected_iface;
|
||||
int errors = 0;
|
||||
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
std::unordered_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
std::unordered_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
bool rescale = true;
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
|
@ -904,7 +906,7 @@ namespace Net {
|
|||
} // 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_IFLIST2, 0};
|
||||
size_t len;
|
||||
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
||||
|
@ -978,7 +980,6 @@ namespace Net {
|
|||
else
|
||||
it++;
|
||||
}
|
||||
net.compact();
|
||||
}
|
||||
|
||||
timestamp = new_timestamp;
|
||||
|
@ -1049,7 +1050,7 @@ namespace Net {
|
|||
namespace Proc {
|
||||
|
||||
vector<proc_info> current_procs;
|
||||
unordered_flat_map<string, string> uid_user;
|
||||
std::unordered_map<string, string> uid_user;
|
||||
string current_sort;
|
||||
string current_filter;
|
||||
bool current_rev = false;
|
||||
|
|
Loading…
Reference in a new issue