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

Cache DisplaySourceSet as it's stored a lot inside of ContentPages #4008

Merged
merged 5 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Use getOrPut extension instead of computeIfAbsent"
This reverts commit bd73593.
  • Loading branch information
whyoleg committed Jan 30, 2025
commit 2122095205f20af9ccb11b5f28db9d2d90c4f122
Original file line number Diff line number Diff line change
@@ -75,15 +75,15 @@ internal object DisplaySourceSetCaches {
* In reality, there will be only several [DokkaSourceSet] instances during Dokka execution.
*/
fun displaySourceSet(sourceSet: DokkaSourceSet): DisplaySourceSet {
return instanceCache.getOrPut(sourceSet) { DisplaySourceSet(sourceSet) }
return instanceCache.computeIfAbsent(sourceSet, ::DisplaySourceSet)
}

/**
* [toDisplaySourceSets] mostly called on the same Set<DokkaSourceSet>,
* so it makes sense to cache them by the set itself.
*/
fun displaySourceSets(sourceSets: Iterable<DokkaSourceSet>): Set<DisplaySourceSet> {
return setCache.getOrPut(sourceSets) { sourceSets.map(::displaySourceSet).toSet() }
return setCache.computeIfAbsent(sourceSets) { it.map(::displaySourceSet).toSet() }
}

fun clear() {