Fix clang warnings on some utils function. It’s also faster

This commit is contained in:
louiz’
2020-05-09 14:40:56 +02:00
parent c671da13b3
commit f76cd93aff
2 changed files with 5 additions and 11 deletions
+3 -9
View File
@@ -7,17 +7,11 @@
namespace utils namespace utils
{ {
inline std::string empty_if_fixed_server(std::string&& str) inline const std::string& empty_if_fixed_server(const std::string& str)
{ {
static const std::string empty{};
if (!Config::get("fixed_irc_server", "").empty()) if (!Config::get("fixed_irc_server", "").empty())
return {}; return empty;
return std::move(str);
}
inline std::string empty_if_fixed_server(const std::string& str)
{
if (!Config::get("fixed_irc_server", "").empty())
return {};
return str; return str;
} }
+2 -2
View File
@@ -6,13 +6,13 @@ bool is_empty(const std::string& val);
bool is_empty(const int& val); bool is_empty(const int& val);
template <typename T> template <typename T>
T get_first_non_empty(T&& last) T& get_first_non_empty(T&& last)
{ {
return last; return last;
} }
template <typename T, typename... Args> template <typename T, typename... Args>
T get_first_non_empty(T&& first, Args&&... args) T& get_first_non_empty(T&& first, Args&&... args)
{ {
if (!is_empty(first)) if (!is_empty(first))
return first; return first;