From 9c1bd449767e243193d50ce135a8ceb758a309fb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 3 Nov 2019 00:56:36 +0100 Subject: [PATCH] =?utf8?q?=E2=99=BB=EF=B8=8F=20Simplify=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt index b40484e..417894e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt @@ -31,7 +31,7 @@ class IdentityLoader @Inject constructor(private val webOfTrustConnector: WebOfT private val logger: Logger = Logger.getLogger(IdentityLoader::class.java.name) @Throws(WebOfTrustException::class) - fun loadIdentities(): Map> = + fun loadIdentities() = time({ stopwatch, identities -> "Loaded ${identities.size} own identities in ${stopwatch.elapsed(MILLISECONDS) / 1000.0}s." }) { webOfTrustConnector.loadAllOwnIdentities() }.let(this::loadTrustedIdentitiesForOwnIdentities) @@ -40,7 +40,7 @@ class IdentityLoader @Inject constructor(private val webOfTrustConnector: WebOfT private fun loadTrustedIdentitiesForOwnIdentities(ownIdentities: Collection) = ownIdentities.associateWith { ownIdentity -> if (ownIdentity.doesNotHaveCorrectContext()) { - emptySet() + emptySet() } else { time({ stopwatch, identities -> "Loaded ${identities.size} identities for ${ownIdentity.nickname} in ${stopwatch.elapsed(MILLISECONDS) / 1000.0}s." }) { webOfTrustConnector.loadTrustedIdentities(ownIdentity, context?.context) @@ -51,7 +51,7 @@ class IdentityLoader @Inject constructor(private val webOfTrustConnector: WebOfT private fun OwnIdentity.doesNotHaveCorrectContext() = context?.let { it.context !in contexts } ?: false - private fun time(logMessage: (Stopwatch, Collection) -> String, loader: () -> Collection): Collection = + private fun time(logMessage: (Stopwatch, R) -> String, loader: () -> R) = Stopwatch.createStarted().let { stopwatch -> loader().also { logger.fine(logMessage(stopwatch, it)) } } -- 2.7.4