diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/connection.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 701f78c2..81151135 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -1456,12 +1456,14 @@ User* Connection::user(const QString& uId) { if (uId.isEmpty()) return nullptr; + if (const auto v = d->userMap.value(uId, nullptr)) + return v; + // Before creating a user object, check that the user id is well-formed + // (it's faster to just do a lookup above before validation) if (!uId.startsWith('@') || serverPart(uId).isEmpty()) { qCCritical(MAIN) << "Malformed userId:" << uId; return nullptr; } - if (d->userMap.contains(uId)) - return d->userMap.value(uId); auto* user = userFactory()(this, uId); d->userMap.insert(uId, user); emit newUser(user); |