From: David ‘Bombe’ Roden Date: Sat, 23 Feb 2019 08:49:56 +0000 (+0100) Subject: Use Sequence instead of Collection X-Git-Tag: v79^2~97 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1557106d0e373f7efc15faed65f69eb567613a45;p=Sone.git Use Sequence instead of Collection --- diff --git a/src/main/kotlin/net/pterodactylus/sone/utils/Pagination.kt b/src/main/kotlin/net/pterodactylus/sone/utils/Pagination.kt index 772d9c4..5d48d61 100644 --- a/src/main/kotlin/net/pterodactylus/sone/utils/Pagination.kt +++ b/src/main/kotlin/net/pterodactylus/sone/utils/Pagination.kt @@ -44,3 +44,4 @@ class Pagination(private val originalItems: List, pageSize: Int): Iter } fun Iterable.paginate(pageSize: Int) = Pagination(toList(), pageSize) +fun Sequence.paginate(pageSize: Int) = Pagination(toList(), pageSize) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt index 05bad4a..92a856a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt @@ -17,7 +17,7 @@ class KnownSonesPage @Inject constructor(template: Template, webInterface: WebIn override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { getCurrentSone(freenetRequest.toadletContext).let { currentSone -> - webInterface.core.sones + webInterface.core.sones.asSequence() .filterNot { freenetRequest.parameters["filter"] == "followed" && currentSone != null && !currentSone.hasFriend(it.id) } .filterNot { freenetRequest.parameters["filter"] == "not-followed" && currentSone != null && currentSone.hasFriend(it.id) } .filterNot { freenetRequest.parameters["filter"] == "new" && it.isKnown }