Fix clang warnings on some utils function. It’s also faster
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user