aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-07-07 08:12:17 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-07 13:23:26 +0200
commit173e7e2dbda129509748def57aa02950ad93e8f1 (patch)
tree4b76deb12dee1cbe8358f2573e1c7c1c17991be4 /plugins
parent9e8455d8a5285bfbdd92cab1515270f695a9b5d3 (diff)
downloaddokka-173e7e2dbda129509748def57aa02950ad93e8f1.tar.gz
dokka-173e7e2dbda129509748def57aa02950ad93e8f1.tar.bz2
dokka-173e7e2dbda129509748def57aa02950ad93e8f1.zip
Cache location provider
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProviderFactory.kt13
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProviderFactory.kt
index 1918472b..442d2e6d 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProviderFactory.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProviderFactory.kt
@@ -3,10 +3,21 @@ package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.pages.MultimoduleRootPageNode
import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
+import java.util.*
+import java.util.concurrent.ConcurrentHashMap
class DefaultLocationProviderFactory(private val context: DokkaContext) : LocationProviderFactory {
- override fun getLocationProvider(pageNode: RootPageNode) =
+ private val cache = ConcurrentHashMap<CacheWrapper, LocationProvider>()
+
+ override fun getLocationProvider(pageNode: RootPageNode) = cache.computeIfAbsent(CacheWrapper(pageNode)) {
if (pageNode.children.first() is MultimoduleRootPageNode) MultimoduleLocationProvider(pageNode, context)
else DefaultLocationProvider(pageNode, context)
+ }
+}
+
+private class CacheWrapper(val pageNode: RootPageNode) {
+ override fun equals(other: Any?) = other is CacheWrapper && other.pageNode == this.pageNode
+
+ override fun hashCode() = System.identityHashCode(pageNode)
} \ No newline at end of file