Skip to content

Commit

Permalink
Replace Path.toRealPath in K1 analysis to improve performance a bit (
Browse files Browse the repository at this point in the history
  • Loading branch information
whyoleg committed May 15, 2024
1 parent b5d74f7 commit 26876e1
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ internal class DefaultDescriptorToDocumentableTranslator(

return DokkaDescriptorVisitor(sourceSet, kdocFinder, kotlinAnalysis[sourceSet], context.logger, javadocParser).run {
packageFragments.parallelMap {
visitPackageFragmentDescriptor(
it
)
visitPackageFragmentDescriptor(it)
}
}.let {
DModule(
Expand Down Expand Up @@ -167,15 +165,16 @@ private class DokkaDescriptorVisitor(
) {
private val syntheticDocProvider = SyntheticDescriptorDocumentationProvider(kDocFinder, sourceSet)

// in most cases it will contain just 1 element
private val sourceRoots = sourceSet.sourceRoots.map { it.toPath().toAbsolutePath().normalize() }
private fun Collection<DeclarationDescriptor>.filterDescriptorsInSourceSet() = filter {
// the path returned from compiler is already absolute and normalized
val pathString = it.toSourceElement.containingFile.toString()
when {
pathString.isBlank() -> false
else -> {
val absolutePath = Paths.get(pathString).toRealPath()
sourceSet.sourceRoots.any { root ->
absolutePath.startsWith(root.toPath().toRealPath())
}
val path = Paths.get(pathString)
sourceRoots.any { root -> path.startsWith(root) }
}
}
}
Expand Down

0 comments on commit 26876e1

Please sign in to comment.