diff options
-rw-r--r-- | lib/user.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/user.cpp b/lib/user.cpp index fdb82a38..7f3f11f6 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -50,21 +50,23 @@ class User::Private return Avatar(move(url)); } - qreal makeHueF(QString userId) + qreal makeHueF() { + Q_ASSERT(!userId.isEmpty()); QByteArray hash = QCryptographicHash::hash(userId.toUtf8(), QCryptographicHash::Sha1); QDataStream dataStream(qToLittleEndian(hash).left(2)); dataStream.setByteOrder(QDataStream::LittleEndian); quint16 hashValue; dataStream >> hashValue; - qreal hueF = static_cast<qreal>(hashValue)/std::numeric_limits<quint16>::max(); + const auto hueF = + qreal(hashValue)/std::numeric_limits<quint16>::max(); Q_ASSERT((0 <= hueF) && (hueF <= 1)); return hueF; } Private(QString userId, Connection* connection) - : userId(move(userId)), connection(connection), hueF(makeHueF(userId)) + : userId(move(userId)), connection(connection), hueF(makeHueF()) { } QString userId; |