From 95075bd1d080f201cc237a542822de2661f3f242 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 21 Dec 2021 17:21:54 +0530 Subject: [PATCH] diceware: switch to `buildString` lambda --- .../passgen/diceware/DicewarePassphraseGenerator.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt b/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt index ee18352e..62e3b97b 100644 --- a/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt +++ b/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt @@ -23,15 +23,12 @@ constructor( /** Generates a passphrase with [wordCount] words. */ public fun generatePassphrase(wordCount: Int, separator: Char): String { - return StringBuilder() - .apply { - repeat(wordCount) { idx -> - append(wordMap[die.rollMultiple(DIGITS)]) - if (idx < wordCount - 1) append(separator) - } + return buildString { + repeat(wordCount) { idx -> + append(wordMap[die.rollMultiple(DIGITS)]) + if (idx < wordCount - 1) append(separator) } - .toString() - .trimEnd() + } } private companion object {