~singpolyma/biboumi

f76cd93aff1610c9b4c720a73f6d585e8008dfd1 — louiz’ 2 years ago c671da1
Fix clang warnings on some utils function. It’s also faster
2 files changed, 5 insertions(+), 11 deletions(-)

M src/utils/empty_if_fixed_server.hpp
M src/utils/get_first_non_empty.hpp
M src/utils/empty_if_fixed_server.hpp => src/utils/empty_if_fixed_server.hpp +3 -9
@@ 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;
  }


M src/utils/get_first_non_empty.hpp => src/utils/get_first_non_empty.hpp +2 -2
@@ 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;