aboutsummaryrefslogtreecommitdiff
path: root/lib/user.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-04-04 21:27:38 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-04-06 20:32:48 +0900
commit432e7fd7107d8260e0016a1adcd8d94263dc1044 (patch)
tree71171a541e508f7a97b1d843c707c7ef296374cb /lib/user.cpp
parent8035ec464ce797abab5e464c2cfb485f7fa14d06 (diff)
downloadlibquotient-432e7fd7107d8260e0016a1adcd8d94263dc1044.tar.gz
libquotient-432e7fd7107d8260e0016a1adcd8d94263dc1044.zip
Clean up on clang-tidy/clazy analysis
Diffstat (limited to 'lib/user.cpp')
-rw-r--r--lib/user.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index 951ad87d..17db5760 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -59,7 +59,7 @@ class User::Private
QMultiHash<QString, const Room*> otherNames;
Avatar mostUsedAvatar { makeAvatar({}) };
std::vector<Avatar> otherAvatars;
- auto otherAvatar(QUrl url)
+ auto otherAvatar(const QUrl& url)
{
return std::find_if(otherAvatars.begin(), otherAvatars.end(),
[&url] (const auto& av) { return av.url() == url; });
@@ -69,7 +69,7 @@ class User::Private
mutable int totalRooms = 0;
QString nameForRoom(const Room* r, const QString& hint = {}) const;
- void setNameForRoom(const Room* r, QString newName, QString oldName);
+ void setNameForRoom(const Room* r, QString newName, const QString& oldName);
QUrl avatarUrlForRoom(const Room* r, const QUrl& hint = {}) const;
void setAvatarForRoom(const Room* r, const QUrl& newUrl,
const QUrl& oldUrl);
@@ -91,7 +91,7 @@ QString User::Private::nameForRoom(const Room* r, const QString& hint) const
static constexpr int MIN_JOINED_ROOMS_TO_LOG = 20;
void User::Private::setNameForRoom(const Room* r, QString newName,
- QString oldName)
+ const QString& oldName)
{
Q_ASSERT(oldName != newName);
Q_ASSERT(oldName == mostUsedName || otherNames.contains(oldName, r));
@@ -118,7 +118,8 @@ void User::Private::setNameForRoom(const Room* r, QString newName,
et.start();
}
- for (auto* r1: connection->roomMap())
+ const auto& roomMap = connection->roomMap();
+ for (auto* r1: roomMap)
if (nameForRoom(r1) == mostUsedName)
otherNames.insert(mostUsedName, r1);
@@ -178,7 +179,8 @@ void User::Private::setAvatarForRoom(const Room* r, const QUrl& newUrl,
auto nextMostUsedIt = otherAvatar(newUrl);
Q_ASSERT(nextMostUsedIt != otherAvatars.end());
std::swap(mostUsedAvatar, *nextMostUsedIt);
- for (const auto* r1: connection->roomMap())
+ const auto& roomMap = connection->roomMap();
+ for (const auto* r1: roomMap)
if (avatarUrlForRoom(r1) == nextMostUsedIt->url())
avatarsToRooms.insert(nextMostUsedIt->url(), r1);
@@ -399,7 +401,7 @@ void User::processEvent(const RoomMemberEvent& event, const Room* room,
// exceptionally rare (the only reasonable case being that the bridge
// changes the naming convention). For the same reason room-specific
// bridge tags are not supported at all.
- QRegularExpression reSuffix(" \\((IRC|Gitter|Telegram)\\)$");
+ QRegularExpression reSuffix(QStringLiteral(" \\((IRC|Gitter|Telegram)\\)$"));
auto match = reSuffix.match(newName);
if (match.hasMatch())
{