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 {
string lower{string_util::lower(forward<string>(value))};
if (lower == "true") {
return true;
} else if (lower == "yes") {
return true;
} else if (lower == "on") {
return true;
} else if (lower == "1") {
return true;
} else {
return false;
}
return (lower == "true" || lower == "yes" || lower == "on" || lower == "1");
}
template <>

View File

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

View File

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

View File

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