Skip to content

Commit

Permalink
Use getOrPut extension instead of computeIfAbsent
Browse files Browse the repository at this point in the history
  • Loading branch information
whyoleg committed Jan 29, 2025
1 parent 80be415 commit bd73593
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.computeIfAbsent(sourceSet, ::DisplaySourceSet)
return instanceCache.getOrPut(sourceSet) { DisplaySourceSet(sourceSet) }
}

/**
* [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.computeIfAbsent(sourceSets) { it.map(::displaySourceSet).toSet() }
return setCache.getOrPut(sourceSets) { sourceSets.map(::displaySourceSet).toSet() }
}

fun clear() {
Expand Down

0 comments on commit bd73593

Please sign in to comment.