summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2020-05-04 23:55:39 +0200
committerlouiz’ <louiz@louiz.org>2020-05-09 14:40:56 +0200
commitf76cd93aff1610c9b4c720a73f6d585e8008dfd1 (patch)
treeeef71f4e81e72bda3068687185de5e427a1bd8a1
parentc671da13b38dcc15d0a441b1b9c258cb12966fca (diff)
downloadbiboumi-f76cd93aff1610c9b4c720a73f6d585e8008dfd1.tar.gz
biboumi-f76cd93aff1610c9b4c720a73f6d585e8008dfd1.tar.bz2
biboumi-f76cd93aff1610c9b4c720a73f6d585e8008dfd1.tar.xz
biboumi-f76cd93aff1610c9b4c720a73f6d585e8008dfd1.zip
Fix clang warnings on some utils function. It’s also faster
-rw-r--r--src/utils/empty_if_fixed_server.hpp12
-rw-r--r--src/utils/get_first_non_empty.hpp4
2 files changed, 5 insertions, 11 deletions
diff --git a/src/utils/empty_if_fixed_server.hpp b/src/utils/empty_if_fixed_server.hpp
index cbb9cea..2422ee4 100644
--- a/src/utils/empty_if_fixed_server.hpp
+++ b/src/utils/empty_if_fixed_server.hpp
@@ -7,17 +7,11 @@
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())
- return {};
- return std::move(str);
- }
-
- inline std::string empty_if_fixed_server(const std::string& str)
- {
- if (!Config::get("fixed_irc_server", "").empty())
- return {};
+ return empty;
return str;
}
diff --git a/src/utils/get_first_non_empty.hpp b/src/utils/get_first_non_empty.hpp
index a38f5fb..2e1828d 100644
--- a/src/utils/get_first_non_empty.hpp
+++ b/src/utils/get_first_non_empty.hpp
@@ -6,13 +6,13 @@ bool is_empty(const std::string& val);
bool is_empty(const int& val);
template <typename T>
-T get_first_non_empty(T&& last)
+T& get_first_non_empty(T&& last)
{
return last;
}
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))
return first;