refactor: Simplify if statements (#1381)

This commit is contained in:
BO41 2018-08-14 23:31:44 +02:00 committed by Patrick Ziegler
parent 2a3b2b2b99
commit 238f8fb592
4 changed files with 4 additions and 28 deletions

View File

@ -238,17 +238,7 @@ template <>
bool config::convert(string&& value) const { bool config::convert(string&& value) const {
string lower{string_util::lower(forward<string>(value))}; string lower{string_util::lower(forward<string>(value))};
if (lower == "true") { return (lower == "true" || lower == "yes" || lower == "on" || lower == "1");
return true;
} else if (lower == "yes") {
return true;
} else if (lower == "on") {
return true;
} else if (lower == "1") {
return true;
} else {
return false;
}
} }
template <> template <>

View File

@ -34,11 +34,7 @@ namespace drawtypes {
void progressbar::set_colors(vector<string>&& colors) { void progressbar::set_colors(vector<string>&& colors) {
m_colors = forward<decltype(colors)>(colors); m_colors = forward<decltype(colors)>(colors);
if (m_colors.empty()) { m_colorstep = m_colors.empty() ? 1 : m_width / m_colors.size();
m_colorstep = 1;
} else {
m_colorstep = m_width / m_colors.size();
}
} }
string progressbar::output(float percentage) { string progressbar::output(float percentage) {

View File

@ -38,15 +38,7 @@ void remove_pipe(const string& handle) {
} }
bool validate_type(const string& type) { bool validate_type(const string& type) {
if (type == "action") { return (type == "action" || type == "cmd" || type == "hook");
return true;
} else if (type == "cmd") {
return true;
} else if (type == "hook") {
return true;
} else {
return false;
}
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {

View File

@ -4,9 +4,7 @@ POLYBAR_NS
namespace cursor_util { namespace cursor_util {
bool valid(string name) { bool valid(string name) {
if (cursors.find(name) != cursors.end()) return (cursors.find(name) != cursors.end());
return true;
return false;
} }
bool set_cursor(xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t w, string name) { bool set_cursor(xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t w, string name) {