diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index f7d1ff80c..3047d31ed 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -292,7 +292,7 @@ namespace Draw { } bool update_clock(bool force) { - const auto& clock_format = Config::getS("clock_format"); + const std::string_view clock_format = Config::getS("clock_format"); if (not Cpu::shown or clock_format.empty()) { if (clock_format.empty() and not Global::clock.empty()) Global::clock.clear(); return false; diff --git a/src/btop_log.cpp b/src/btop_log.cpp index 17d63b85f..286ca6f61 100644 --- a/src/btop_log.cpp +++ b/src/btop_log.cpp @@ -27,10 +27,10 @@ namespace Logger { using namespace Tools; std::mutex log_mtx{}; bool first = true; - const string tdf = "%Y/%m/%d (%T) | "; size_t loglevel; fs::path logfile; + constexpr const std::string_view tdf = "%Y/%m/%d (%T) | "; //* Wrapper for lowering priviliges if using SUID bit and currently isn't using real userid class lose_priv { diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index 90b7e7c66..f673a1ddd 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -18,13 +18,15 @@ tab-size = 4 #include #include -#include -#include #include -#include +#include #include -#include +#include #include +#include +#include +#include +#include #include #include @@ -473,11 +475,11 @@ namespace Tools { return new_str; } - string strf_time(const string& strf) { + string strf_time(const std::string_view strf) { auto in_time_t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::tm bt {}; std::stringstream ss; - ss << std::put_time(localtime_r(&in_time_t, &bt), strf.c_str()); + ss << std::put_time(localtime_r(&in_time_t, &bt), strf.data()); return ss.str(); } diff --git a/src/btop_tools.hpp b/src/btop_tools.hpp index 9593d4b3f..ed7cf315d 100644 --- a/src/btop_tools.hpp +++ b/src/btop_tools.hpp @@ -26,6 +26,7 @@ tab-size = 4 #include #include #include +#include #include #include #include @@ -297,7 +298,7 @@ namespace Tools { std::string operator*(const string& str, int64_t n); //* Return current time in format - string strf_time(const string& strf); + string strf_time(const std::string_view strf); string hostname(); string username();