From 4ecb1680bfca1a29adb99f63f0bb176cec687442 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 11 Jun 2026 12:11:54 -0400 Subject: [PATCH] fix(android): drop second loop jump in supersededLikeToggleIds (detekt) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LoopWithTooManyJumpStatements — replace the two continues with a filtered sequence + a single null guard. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../cache/mutations/MutationReplayer.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/java/com/fabledsword/minstrel/cache/mutations/MutationReplayer.kt b/android/app/src/main/java/com/fabledsword/minstrel/cache/mutations/MutationReplayer.kt index 6d08a5f8..a09c1301 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/cache/mutations/MutationReplayer.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/cache/mutations/MutationReplayer.kt @@ -135,15 +135,18 @@ class MutationReplayer @Inject constructor( private fun supersededLikeToggleIds(rows: List): Set { val latestByEntity = HashMap() val superseded = HashSet() - for (row in rows) { - if (row.kind != MutationKind.LIKE_TOGGLE) continue - val decoded = runCatching { - json.decodeFromString(LikeTogglePayload.serializer(), row.payload) - }.getOrNull() ?: continue - val key = "${decoded.entityType}:${decoded.entityId}" - // `rows` is ascending by id, so a prior entry is always older. - latestByEntity.put(key, row.id)?.let(superseded::add) - } + rows.asSequence() + .filter { it.kind == MutationKind.LIKE_TOGGLE } + .forEach { row -> + val decoded = runCatching { + json.decodeFromString(LikeTogglePayload.serializer(), row.payload) + }.getOrNull() + if (decoded != null) { + val key = "${decoded.entityType}:${decoded.entityId}" + // `rows` is ascending by id, so a prior entry is always older. + latestByEntity.put(key, row.id)?.let(superseded::add) + } + } return superseded }