Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix silly bug about indexes starting at 2 #618

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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