From a34b053efe775b992c486e180d0552f3a17d537e Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Sun, 21 Jul 2019 23:35:38 +0100 Subject: [PATCH] Some optimisations Signed-off-by: Dominic Fischer --- .../internal/crypto/keysbackup/KeysBackupPassword.kt | 11 +++++------ .../matrix/android/internal/crypto/model/MXKey.kt | 4 +--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt index 51346c89..e1ada61b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt @@ -142,12 +142,11 @@ private fun deriveKey(password: String, * Generate a 32 chars salt */ private fun generateSalt(): String { - var salt = "" - - do { - salt += UUID.randomUUID().toString() - } while (salt.length < SALT_LENGTH) - + val salt = buildString { + do { + append(UUID.randomUUID().toString()) + } while (length < SALT_LENGTH) + } return salt.substring(0, SALT_LENGTH) } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt index db0f2652..69019fbb 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt @@ -63,9 +63,7 @@ data class MXKey( fun signatureForUserId(userId: String, signkey: String): String? { // sanity checks if (userId.isNotBlank() && signkey.isNotBlank()) { - if (signatures.containsKey(userId)) { - return signatures[userId]?.get(signkey) - } + return signatures[userId]?.get(signkey) } return null