Merge pull request #417 from Dominaezzz/kt-opt

Some optimisations
This commit is contained in:
Benoit Marty 2019-08-06 11:42:07 +02:00 committed by GitHub
commit ed6d28bd3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View file

@ -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)
}

View file

@ -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