From 10d683354b739ae2567c7898ae11479413dc475a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 4 May 2020 23:55:39 +0200 Subject: =?UTF-8?q?Fix=20clang=20warnings=20on=20some=20utils=20function.?= =?UTF-8?q?=20It=E2=80=99s=20also=20faster?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/empty_if_fixed_server.hpp | 12 +++--------- src/utils/get_first_non_empty.hpp | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src') 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 1877ee8..6129b63 100644 --- a/src/utils/get_first_non_empty.hpp +++ b/src/utils/get_first_non_empty.hpp @@ -11,13 +11,13 @@ template <> bool is_empty(const std::string& val); template -T get_first_non_empty(T&& last) +T& get_first_non_empty(T&& last) { return last; } template -T get_first_non_empty(T&& first, Args&&... args) +T& get_first_non_empty(T&& first, Args&&... args) { if (!is_empty(first)) return first; -- cgit v1.2.3