From 0421b5b05f06b12dbdb185c1c842af94d72b4b23 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Sun, 29 Jul 2018 17:38:01 +0200 Subject: [PATCH] refactor: Remove unnecessary quote trim operations Trimming the quotes in labels and the date module are not needed at all, because surrounding quotes are removed when loading the values from the config. Removing the quotes in the builder also doesn't seem to serve any purpose at all. --- src/components/builder.cpp | 4 ---- src/drawtypes/label.cpp | 6 ------ src/modules/date.cpp | 8 ++++---- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/components/builder.cpp b/src/components/builder.cpp index f37cb46b..bce01ab9 100644 --- a/src/components/builder.cpp +++ b/src/components/builder.cpp @@ -90,10 +90,6 @@ void builder::node(string str, bool add_space) { string::size_type n, m; string s(move(str)); - if ((n = s.size()) > 2 && s[0] == '"' && s[n - 1] == '"') { - s = s.substr(1, n - 2); - } - while (true) { if (s.empty()) { break; diff --git a/src/drawtypes/label.cpp b/src/drawtypes/label.cpp index 1ec4c776..a9e5a626 100644 --- a/src/drawtypes/label.cpp +++ b/src/drawtypes/label.cpp @@ -151,12 +151,6 @@ namespace drawtypes { text = conf.get(section, name, move(def)); } - size_t len{text.size()}; - - if (len > 2 && text[0] == '"' && text[len - 1] == '"') { - text = text.substr(1, len - 2); - } - const auto get_left_right = [&](string key) { auto value = conf.get(section, key, 0U); auto left = conf.get(section, key + "-left", value); diff --git a/src/modules/date.cpp b/src/modules/date.cpp index 048605bd..dc381791 100644 --- a/src/modules/date.cpp +++ b/src/modules/date.cpp @@ -13,10 +13,10 @@ namespace modules { datetime_stream.imbue(std::locale(m_bar.locale.c_str())); } - m_dateformat = string_util::trim(m_conf.get(name(), "date", ""s), '"'); - m_dateformat_alt = string_util::trim(m_conf.get(name(), "date-alt", ""s), '"'); - m_timeformat = string_util::trim(m_conf.get(name(), "time", ""s), '"'); - m_timeformat_alt = string_util::trim(m_conf.get(name(), "time-alt", ""s), '"'); + m_dateformat = m_conf.get(name(), "date", ""s); + m_dateformat_alt = m_conf.get(name(), "date-alt", ""s); + m_timeformat = m_conf.get(name(), "time", ""s); + m_timeformat_alt = m_conf.get(name(), "time-alt", ""s); if (m_dateformat.empty() && m_timeformat.empty()) { throw module_error("No date or time format specified");