mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-28 06:11:28 +02:00
Fix variable initialization to 'auto' for getB()
It does not make sense to return a `const bool&` as we are dealing with Boolean literals that are `prvalue`s of type bool. The compiler is smart enough to do the necessary optimizations wherever is applicable.
This commit is contained in:
parent
36a180033d
commit
ab7fe62e65
@ -113,10 +113,3 @@ namespace Config {
|
|||||||
//* Write the config file to disk
|
//* Write the config file to disk
|
||||||
void write();
|
void write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,8 +232,8 @@ namespace Draw {
|
|||||||
const string title, const string title2, const int num) {
|
const string title, const string title2, const int num) {
|
||||||
string out;
|
string out;
|
||||||
if (line_color.empty()) line_color = Theme::c("div_line");
|
if (line_color.empty()) line_color = Theme::c("div_line");
|
||||||
const auto tty_mode = Config::getB("tty_mode");
|
auto tty_mode = Config::getB("tty_mode");
|
||||||
const auto rounded = Config::getB("rounded_corners");
|
auto rounded = Config::getB("rounded_corners");
|
||||||
const string numbering = (num == 0) ? "" : Theme::c("hi_fg") + (tty_mode ? std::to_string(num) : Symbols::superscript.at(clamp(num, 0, 9)));
|
const string numbering = (num == 0) ? "" : Theme::c("hi_fg") + (tty_mode ? std::to_string(num) : Symbols::superscript.at(clamp(num, 0, 9)));
|
||||||
const auto& right_up = (tty_mode or not rounded ? Symbols::right_up : Symbols::round_right_up);
|
const auto& right_up = (tty_mode or not rounded ? Symbols::right_up : Symbols::round_right_up);
|
||||||
const auto& left_up = (tty_mode or not rounded ? Symbols::left_up : Symbols::round_left_up);
|
const auto& left_up = (tty_mode or not rounded ? Symbols::left_up : Symbols::round_left_up);
|
||||||
@ -300,7 +300,7 @@ namespace Draw {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto& out = Global::clock;
|
auto& out = Global::clock;
|
||||||
const auto& cpu_bottom = Config::getB("cpu_bottom");
|
auto cpu_bottom = Config::getB("cpu_bottom");
|
||||||
const auto& x = Cpu::x;
|
const auto& x = Cpu::x;
|
||||||
const auto y = (cpu_bottom ? Cpu::y + Cpu::height - 1 : Cpu::y);
|
const auto y = (cpu_bottom ? Cpu::y + Cpu::height - 1 : Cpu::y);
|
||||||
const auto& width = Cpu::width;
|
const auto& width = Cpu::width;
|
||||||
@ -503,9 +503,9 @@ namespace Cpu {
|
|||||||
string draw(const cpu_info& cpu, const bool force_redraw, const bool data_same) {
|
string draw(const cpu_info& cpu, const bool force_redraw, const bool data_same) {
|
||||||
if (Runner::stopping) return "";
|
if (Runner::stopping) return "";
|
||||||
if (force_redraw) redraw = true;
|
if (force_redraw) redraw = true;
|
||||||
const bool show_temps = (Config::getB("check_temp") and got_sensors);
|
bool show_temps = (Config::getB("check_temp") and got_sensors);
|
||||||
auto single_graph = Config::getB("cpu_single_graph");
|
auto single_graph = Config::getB("cpu_single_graph");
|
||||||
const bool hide_cores = show_temps and (cpu_temp_only or not Config::getB("show_coretemp"));
|
bool hide_cores = show_temps and (cpu_temp_only or not Config::getB("show_coretemp"));
|
||||||
const int extra_width = (hide_cores ? max(6, 6 * b_column_size) : 0);
|
const int extra_width = (hide_cores ? max(6, 6 * b_column_size) : 0);
|
||||||
auto& graph_up_field = Config::getS("cpu_graph_upper");
|
auto& graph_up_field = Config::getS("cpu_graph_upper");
|
||||||
auto& graph_lo_field = Config::getS("cpu_graph_lower");
|
auto& graph_lo_field = Config::getS("cpu_graph_lower");
|
||||||
@ -1590,7 +1590,7 @@ namespace Draw {
|
|||||||
//* Calculate and draw cpu box outlines
|
//* Calculate and draw cpu box outlines
|
||||||
if (Cpu::shown) {
|
if (Cpu::shown) {
|
||||||
using namespace Cpu;
|
using namespace Cpu;
|
||||||
const bool show_temp = (Config::getB("check_temp") and got_sensors);
|
bool show_temp = (Config::getB("check_temp") and got_sensors);
|
||||||
width = round((double)Term::width * width_p / 100);
|
width = round((double)Term::width * width_p / 100);
|
||||||
height = max(8, (int)ceil((double)Term::height * (trim(boxes) == "cpu" ? 100 : height_p) / 100));
|
height = max(8, (int)ceil((double)Term::height * (trim(boxes) == "cpu" ? 100 : height_p) / 100));
|
||||||
x = 1;
|
x = 1;
|
||||||
|
@ -632,8 +632,8 @@ namespace Menu {
|
|||||||
msgBox::msgBox() {}
|
msgBox::msgBox() {}
|
||||||
msgBox::msgBox(int width, int boxtype, vector<string> content, string title)
|
msgBox::msgBox(int width, int boxtype, vector<string> content, string title)
|
||||||
: width(width), boxtype(boxtype) {
|
: width(width), boxtype(boxtype) {
|
||||||
const auto& tty_mode = Config::getB("tty_mode");
|
auto tty_mode = Config::getB("tty_mode");
|
||||||
const auto& rounded = Config::getB("rounded_corners");
|
auto rounded = Config::getB("rounded_corners");
|
||||||
const auto& right_up = (tty_mode or not rounded ? Symbols::right_up : Symbols::round_right_up);
|
const auto& right_up = (tty_mode or not rounded ? Symbols::right_up : Symbols::round_right_up);
|
||||||
const auto& left_up = (tty_mode or not rounded ? Symbols::left_up : Symbols::round_left_up);
|
const auto& left_up = (tty_mode or not rounded ? Symbols::left_up : Symbols::round_left_up);
|
||||||
const auto& right_down = (tty_mode or not rounded ? Symbols::right_down : Symbols::round_right_down);
|
const auto& right_down = (tty_mode or not rounded ? Symbols::right_down : Symbols::round_right_down);
|
||||||
@ -722,7 +722,7 @@ namespace Menu {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int signalChoose(const string& key) {
|
int signalChoose(const string& key) {
|
||||||
auto& s_pid = (Config::getB("show_detailed") and Config::getI("selected_pid") == 0 ? Config::getI("detailed_pid") : Config::getI("selected_pid"));
|
auto s_pid = (Config::getB("show_detailed") and Config::getI("selected_pid") == 0 ? Config::getI("detailed_pid") : Config::getI("selected_pid"));
|
||||||
static int x{}; // defaults to 0
|
static int x{}; // defaults to 0
|
||||||
static int y{}; // defaults to 0
|
static int y{}; // defaults to 0
|
||||||
static int selected_signal = -1;
|
static int selected_signal = -1;
|
||||||
@ -852,7 +852,7 @@ namespace Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int signalSend(const string& key) {
|
int signalSend(const string& key) {
|
||||||
auto& s_pid = (Config::getB("show_detailed") and Config::getI("selected_pid") == 0 ? Config::getI("detailed_pid") : Config::getI("selected_pid"));
|
auto s_pid = (Config::getB("show_detailed") and Config::getI("selected_pid") == 0 ? Config::getI("detailed_pid") : Config::getI("selected_pid"));
|
||||||
if (s_pid == 0) return Closed;
|
if (s_pid == 0) return Closed;
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
atomic_wait(Runner::active);
|
atomic_wait(Runner::active);
|
||||||
|
@ -349,7 +349,7 @@ namespace Tools {
|
|||||||
string floating_humanizer(uint64_t value, const bool shorten, size_t start, const bool bit, const bool per_second) {
|
string floating_humanizer(uint64_t value, const bool shorten, size_t start, const bool bit, const bool per_second) {
|
||||||
string out;
|
string out;
|
||||||
const size_t mult = (bit) ? 8 : 1;
|
const size_t mult = (bit) ? 8 : 1;
|
||||||
const bool mega = Config::getB("base_10_sizes");
|
bool mega = Config::getB("base_10_sizes");
|
||||||
|
|
||||||
// taking advantage of type deduction for array creation (since C++17)
|
// taking advantage of type deduction for array creation (since C++17)
|
||||||
// combined with string literals (operator""s)
|
// combined with string literals (operator""s)
|
||||||
|
@ -614,9 +614,9 @@ namespace Mem {
|
|||||||
if (Runner::stopping or (no_update and not current_mem.percent.at("used").empty()))
|
if (Runner::stopping or (no_update and not current_mem.percent.at("used").empty()))
|
||||||
return current_mem;
|
return current_mem;
|
||||||
|
|
||||||
auto &show_swap = Config::getB("show_swap");
|
auto show_swap = Config::getB("show_swap");
|
||||||
auto &show_disks = Config::getB("show_disks");
|
auto show_disks = Config::getB("show_disks");
|
||||||
auto &swap_disk = Config::getB("swap_disk");
|
auto swap_disk = Config::getB("swap_disk");
|
||||||
auto &mem = current_mem;
|
auto &mem = current_mem;
|
||||||
static const bool snapped = (getenv("BTOP_SNAPPED") != NULL);
|
static const bool snapped = (getenv("BTOP_SNAPPED") != NULL);
|
||||||
|
|
||||||
@ -670,7 +670,7 @@ namespace Mem {
|
|||||||
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;
|
||||||
// auto &only_physical = Config::getB("only_physical");
|
// auto only_physical = Config::getB("only_physical");
|
||||||
auto &disks = mem.disks;
|
auto &disks = mem.disks;
|
||||||
vector<string> filter;
|
vector<string> filter;
|
||||||
if (not disks_filter.empty()) {
|
if (not disks_filter.empty()) {
|
||||||
@ -806,8 +806,8 @@ namespace Net {
|
|||||||
auto collect(const bool no_update) -> net_info & {
|
auto collect(const bool no_update) -> net_info & {
|
||||||
auto &net = current_net;
|
auto &net = current_net;
|
||||||
auto &config_iface = Config::getS("net_iface");
|
auto &config_iface = Config::getS("net_iface");
|
||||||
auto &net_sync = Config::getB("net_sync");
|
auto net_sync = Config::getB("net_sync");
|
||||||
auto &net_auto = Config::getB("net_auto");
|
auto net_auto = Config::getB("net_auto");
|
||||||
auto new_timestamp = time_ms();
|
auto new_timestamp = time_ms();
|
||||||
|
|
||||||
if (not no_update and errors < 3) {
|
if (not no_update and errors < 3) {
|
||||||
@ -1080,11 +1080,11 @@ namespace Proc {
|
|||||||
//* Collects and sorts process information from /proc
|
//* Collects and sorts process information from /proc
|
||||||
auto collect(const bool no_update) -> vector<proc_info> & {
|
auto collect(const bool no_update) -> vector<proc_info> & {
|
||||||
const auto &sorting = Config::getS("proc_sorting");
|
const auto &sorting = Config::getS("proc_sorting");
|
||||||
const auto &reverse = Config::getB("proc_reversed");
|
auto reverse = Config::getB("proc_reversed");
|
||||||
const auto &filter = Config::getS("proc_filter");
|
const auto &filter = Config::getS("proc_filter");
|
||||||
const auto &per_core = Config::getB("proc_per_core");
|
auto per_core = Config::getB("proc_per_core");
|
||||||
const auto &tree = Config::getB("proc_tree");
|
auto tree = Config::getB("proc_tree");
|
||||||
const auto &show_detailed = Config::getB("show_detailed");
|
auto show_detailed = Config::getB("show_detailed");
|
||||||
const size_t detailed_pid = Config::getI("detailed_pid");
|
const size_t detailed_pid = Config::getI("detailed_pid");
|
||||||
bool should_filter = current_filter != filter;
|
bool should_filter = current_filter != filter;
|
||||||
if (should_filter) current_filter = filter;
|
if (should_filter) current_filter = filter;
|
||||||
|
@ -1614,12 +1614,12 @@ namespace Proc {
|
|||||||
//* Collects and sorts process information from /proc
|
//* Collects and sorts process information from /proc
|
||||||
auto collect(const bool no_update) -> vector<proc_info>& {
|
auto collect(const bool no_update) -> vector<proc_info>& {
|
||||||
const auto& sorting = Config::getS("proc_sorting");
|
const auto& sorting = Config::getS("proc_sorting");
|
||||||
const auto& reverse = Config::getB("proc_reversed");
|
auto reverse = Config::getB("proc_reversed");
|
||||||
const auto& filter = Config::getS("proc_filter");
|
const auto& filter = Config::getS("proc_filter");
|
||||||
const auto& per_core = Config::getB("proc_per_core");
|
auto per_core = Config::getB("proc_per_core");
|
||||||
const auto& should_filter_kernel = Config::getB("proc_filter_kernel");
|
auto should_filter_kernel = Config::getB("proc_filter_kernel");
|
||||||
const auto& tree = Config::getB("proc_tree");
|
auto tree = Config::getB("proc_tree");
|
||||||
const auto& show_detailed = Config::getB("show_detailed");
|
auto show_detailed = Config::getB("show_detailed");
|
||||||
const size_t detailed_pid = Config::getI("detailed_pid");
|
const size_t detailed_pid = Config::getI("detailed_pid");
|
||||||
bool should_filter = current_filter != filter;
|
bool should_filter = current_filter != filter;
|
||||||
if (should_filter) current_filter = filter;
|
if (should_filter) current_filter = filter;
|
||||||
|
@ -666,9 +666,9 @@ namespace Mem {
|
|||||||
if (Runner::stopping or (no_update and not current_mem.percent.at("used").empty()))
|
if (Runner::stopping or (no_update and not current_mem.percent.at("used").empty()))
|
||||||
return current_mem;
|
return current_mem;
|
||||||
|
|
||||||
auto &show_swap = Config::getB("show_swap");
|
auto show_swap = Config::getB("show_swap");
|
||||||
auto &show_disks = Config::getB("show_disks");
|
auto show_disks = Config::getB("show_disks");
|
||||||
auto &swap_disk = Config::getB("swap_disk");
|
auto swap_disk = Config::getB("swap_disk");
|
||||||
auto &mem = current_mem;
|
auto &mem = current_mem;
|
||||||
static const bool snapped = (getenv("BTOP_SNAPPED") != NULL);
|
static const bool snapped = (getenv("BTOP_SNAPPED") != NULL);
|
||||||
|
|
||||||
@ -712,7 +712,7 @@ namespace Mem {
|
|||||||
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;
|
||||||
// auto &only_physical = Config::getB("only_physical");
|
// auto only_physical = Config::getB("only_physical");
|
||||||
auto &disks = mem.disks;
|
auto &disks = mem.disks;
|
||||||
vector<string> filter;
|
vector<string> filter;
|
||||||
if (not disks_filter.empty()) {
|
if (not disks_filter.empty()) {
|
||||||
@ -845,8 +845,8 @@ namespace Net {
|
|||||||
auto collect(const bool no_update) -> net_info & {
|
auto collect(const bool no_update) -> net_info & {
|
||||||
auto &net = current_net;
|
auto &net = current_net;
|
||||||
auto &config_iface = Config::getS("net_iface");
|
auto &config_iface = Config::getS("net_iface");
|
||||||
auto &net_sync = Config::getB("net_sync");
|
auto net_sync = Config::getB("net_sync");
|
||||||
auto &net_auto = Config::getB("net_auto");
|
auto net_auto = Config::getB("net_auto");
|
||||||
auto new_timestamp = time_ms();
|
auto new_timestamp = time_ms();
|
||||||
|
|
||||||
if (not no_update and errors < 3) {
|
if (not no_update and errors < 3) {
|
||||||
@ -1108,11 +1108,11 @@ namespace Proc {
|
|||||||
//* Collects and sorts process information from /proc
|
//* Collects and sorts process information from /proc
|
||||||
auto collect(const bool no_update) -> vector<proc_info> & {
|
auto collect(const bool no_update) -> vector<proc_info> & {
|
||||||
const auto &sorting = Config::getS("proc_sorting");
|
const auto &sorting = Config::getS("proc_sorting");
|
||||||
const auto &reverse = Config::getB("proc_reversed");
|
auto reverse = Config::getB("proc_reversed");
|
||||||
const auto &filter = Config::getS("proc_filter");
|
const auto &filter = Config::getS("proc_filter");
|
||||||
const auto &per_core = Config::getB("proc_per_core");
|
auto per_core = Config::getB("proc_per_core");
|
||||||
const auto &tree = Config::getB("proc_tree");
|
auto tree = Config::getB("proc_tree");
|
||||||
const auto &show_detailed = Config::getB("show_detailed");
|
auto show_detailed = Config::getB("show_detailed");
|
||||||
const size_t detailed_pid = Config::getI("detailed_pid");
|
const size_t detailed_pid = Config::getI("detailed_pid");
|
||||||
bool should_filter = current_filter != filter;
|
bool should_filter = current_filter != filter;
|
||||||
if (should_filter) current_filter = filter;
|
if (should_filter) current_filter = filter;
|
||||||
|
Loading…
Reference in New Issue
Block a user