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

This commit is contained in:
louiz’
2020-05-04 23:55:39 +02:00
parent c91fac82da
commit 10d683354b
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
@@ -11,13 +11,13 @@ template <>
bool is_empty(const std::string& val); bool is_empty(const std::string& 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;