From 10f6720e8284f6895e4de0e81870c462d641aa40 Mon Sep 17 00:00:00 2001 From: Maciej Procyk Date: Tue, 26 Mar 2024 08:26:36 +0100 Subject: [PATCH] cleanup code --- .../src/main/kotlin/in/procyk/shin/service/ShortUrlService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/kotlin/in/procyk/shin/service/ShortUrlService.kt b/server/src/main/kotlin/in/procyk/shin/service/ShortUrlService.kt index a2c4db9..0f06aa3 100644 --- a/server/src/main/kotlin/in/procyk/shin/service/ShortUrlService.kt +++ b/server/src/main/kotlin/in/procyk/shin/service/ShortUrlService.kt @@ -122,7 +122,8 @@ private fun Shorten.createShortenedIdentifier(): ShortenedIdentifier? { uniqueId = id, takeCounts = sequence { prefix?.let { yield(it.length) } - for (i in 1..id.length) yield((prefix?.let { it.length + 1 } ?: 0) + i) + val shift = prefix?.let { it.length + 1 } ?: 0 + for (i in 1..id.length) yield(shift + i) }, ) } \ No newline at end of file