From 5402a256d1f0ebbeafa32d250d000cf38fe748fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 7 Apr 2017 18:45:24 +0200 Subject: Apply all the clang-tidy modernize-* fixes --- src/irc/iid.cpp | 9 +++++---- src/irc/iid.hpp | 2 +- src/irc/irc_client.cpp | 41 +++++++++++++++++++++-------------------- src/irc/irc_client.hpp | 6 +++--- 4 files changed, 30 insertions(+), 28 deletions(-) (limited to 'src/irc') diff --git a/src/irc/iid.cpp b/src/irc/iid.cpp index 6b07793..63c7039 100644 --- a/src/irc/iid.cpp +++ b/src/irc/iid.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -7,10 +8,10 @@ constexpr char Iid::separator[]; -Iid::Iid(const std::string& local, const std::string& server, Iid::Type type): - type(type), - local(local), - server(server) +Iid::Iid(std::string local, std::string server, Iid::Type type): + type(std::move(type)), + local(std::move(local)), + server(std::move(server)) { } diff --git a/src/irc/iid.hpp b/src/irc/iid.hpp index 81cf3ca..89f4797 100644 --- a/src/irc/iid.hpp +++ b/src/irc/iid.hpp @@ -59,7 +59,7 @@ public: Iid(const std::string& iid, const std::set& chantypes); Iid(const std::string& iid, const std::initializer_list& chantypes); Iid(const std::string& iid, const Bridge* bridge); - Iid(const std::string& local, const std::string& server, Type type); + Iid(std::string local, std::string server, Type type); Iid() = default; Iid(const Iid&) = default; diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 48b105d..710ba15 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -127,16 +128,16 @@ static const std::unordered_map& poller, const std::string& hostname, - const std::string& nickname, const std::string& username, - const std::string& realname, const std::string& user_hostname, +IrcClient::IrcClient(std::shared_ptr& poller, std::string hostname, + std::string nickname, std::string username, + std::string realname, std::string user_hostname, Bridge& bridge): TCPClientSocketHandler(poller), - hostname(hostname), - user_hostname(user_hostname), - username(username), - realname(realname), - current_nick(nickname), + hostname(std::move(hostname)), + user_hostname(std::move(user_hostname)), + username(std::move(username)), + realname(std::move(realname)), + current_nick(std::move(nickname)), bridge(bridge), welcomed(false), chanmodes({"", "", "", ""}), @@ -791,10 +792,10 @@ void IrcClient::on_nickname_conflict(const IrcMessage& message) { const std::string nickname = message.arguments[1]; this->on_generic_error(message); - for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + for (const auto& pair: this->channels) { Iid iid; - iid.set_local(it->first); + iid.set_local(pair.first); iid.set_server(this->hostname); iid.type = Iid::Type::Channel; this->bridge.send_nickname_conflict_error(iid, nickname); @@ -808,10 +809,10 @@ void IrcClient::on_nickname_change_too_fast(const IrcMessage& message) if (message.arguments.size() >= 3) txt = message.arguments[2]; this->on_generic_error(message); - for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + for (const auto& pair: this->channels) { Iid iid; - iid.set_local(it->first); + iid.set_local(pair.first); iid.set_server(this->hostname); iid.type = Iid::Type::Channel; this->bridge.send_presence_error(iid, nickname, @@ -896,13 +897,13 @@ void IrcClient::on_error(const IrcMessage& message) { const std::string leave_message = message.arguments[0]; // The user is out of all the channels - for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + for (const auto& pair: this->channels) { Iid iid; - iid.set_local(it->first); + iid.set_local(pair.first); iid.set_server(this->hostname); iid.type = Iid::Type::Channel; - IrcChannel* channel = it->second.get(); + IrcChannel* channel = pair.second.get(); if (!channel->joined) continue; std::string own_nick = channel->get_self()->nick; @@ -917,10 +918,10 @@ void IrcClient::on_quit(const IrcMessage& message) std::string txt; if (message.arguments.size() >= 1) txt = message.arguments[0]; - for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + for (const auto& pair: this->channels) { - const std::string chan_name = it->first; - IrcChannel* channel = it->second.get(); + const std::string& chan_name = pair.first; + IrcChannel* channel = pair.second.get(); const IrcUser* user = channel->find_user(message.prefix); if (user) { @@ -966,9 +967,9 @@ void IrcClient::on_nick(const IrcMessage& message) { change_nick_func("", &this->get_dummy_channel()); } - for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + for (const auto& pair: this->channels) { - change_nick_func(it->first, it->second.get()); + change_nick_func(pair.first, pair.second.get()); } } diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 8119201..7593029 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -26,9 +26,9 @@ class Bridge; class IrcClient: public TCPClientSocketHandler { public: - explicit IrcClient(std::shared_ptr& poller, const std::string& hostname, - const std::string& nickname, const std::string& username, - const std::string& realname, const std::string& user_hostname, + explicit IrcClient(std::shared_ptr& poller, std::string hostname, + std::string nickname, std::string username, + std::string realname, std::string user_hostname, Bridge& bridge); ~IrcClient(); -- cgit v1.2.3