Skip to content

Commit

Permalink
Fix silly bug about indexes starting at 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Billing committed Sep 29, 2020
1 parent 6491a76 commit e7b0c43
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.security.Key
import javax.crypto.Cipher

object WCIFScrambleMatcher {
const val ID_PENDING = 0 // FIXME should this be -1?
const val ID_PENDING = 0

// SCRAMBLE SET ENCRYPTION / DECRYPTION -----

Expand Down Expand Up @@ -222,9 +222,9 @@ object WCIFScrambleMatcher {
private fun <T : IndexingIdProvider> buildReindexingMap(candidates: List<T>): Map<T, Int> {
val forReindexing = candidates.filter { it.id == ID_PENDING }
val maxAssignedId = (candidates - forReindexing)
.maxByOrNull { it.id }?.id ?: 1
.map { it.id }.maxOrNull() ?: ID_PENDING

return forReindexing.mapIndexed { i, elem -> elem to i + maxAssignedId + 1 }
return forReindexing.mapIndexed { i, elem -> elem to maxAssignedId + 1 + i }
.toMap()
}

Expand Down

0 comments on commit e7b0c43

Please sign in to comment.