[klib] Optimized away some Files.exists()
This commit is contained in:
@@ -54,8 +54,10 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
|||||||
(listOf(currentDirHead) + repoRoots + listOf(localHead, distHead, distPlatformHead)).filterNotNull()
|
(listOf(currentDirHead) + repoRoots + listOf(localHead, distHead, distPlatformHead)).filterNotNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val files: Set<String> by lazy { searchRoots.flatMap { it.listFilesOrEmpty }.map { it.absolutePath }.toSet() }
|
||||||
|
|
||||||
private fun found(candidate: File): File? {
|
private fun found(candidate: File): File? {
|
||||||
fun check(file: File): Boolean = file.exists
|
fun check(file: File): Boolean = files.contains(file.absolutePath) || file.exists
|
||||||
|
|
||||||
val noSuffix = File(candidate.path.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT))
|
val noSuffix = File(candidate.path.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT))
|
||||||
val withSuffix = File(candidate.path.suffixIfNot(KLIB_FILE_EXTENSION_WITH_DOT))
|
val withSuffix = File(candidate.path.suffixIfNot(KLIB_FILE_EXTENSION_WITH_DOT))
|
||||||
@@ -292,4 +294,4 @@ class CompilerSingleFileKlibResolveAllowingIrProvidersStrategy(
|
|||||||
SingleKlibComponentResolver(
|
SingleKlibComponentResolver(
|
||||||
libraryFile.absolutePath, logger, knownIrProviders
|
libraryFile.absolutePath, logger, knownIrProviders
|
||||||
).resolve(libraryFile.absolutePath)
|
).resolve(libraryFile.absolutePath)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,20 +28,21 @@ open class BaseKotlinLibraryImpl(
|
|||||||
override val libraryFile get() = access.klib
|
override val libraryFile get() = access.klib
|
||||||
override val libraryName: String by lazy { access.inPlace { it.libraryName } }
|
override val libraryName: String by lazy { access.inPlace { it.libraryName } }
|
||||||
|
|
||||||
override val componentList: List<String> by lazy {
|
private val componentListAndHasPre14Manifest by lazy {
|
||||||
access.inPlace {
|
access.inPlace { layout ->
|
||||||
it.libDir.listFiles
|
val listFiles = layout.libDir.listFiles
|
||||||
|
listFiles
|
||||||
.filter { it.isDirectory }
|
.filter { it.isDirectory }
|
||||||
.filter { it.listFiles.map { it.name }.contains(KLIB_MANIFEST_FILE_NAME) }
|
.filter { it.listFiles.map { it.name }.contains(KLIB_MANIFEST_FILE_NAME) }
|
||||||
.map { it.name }
|
.map { it.name } to listFiles.any { it.absolutePath == layout.pre_1_4_manifest.absolutePath }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val componentList: List<String> get() = componentListAndHasPre14Manifest.first
|
||||||
|
|
||||||
override fun toString() = "$libraryName[default=$isDefault]"
|
override fun toString() = "$libraryName[default=$isDefault]"
|
||||||
|
|
||||||
override val has_pre_1_4_manifest: Boolean by lazy {
|
override val has_pre_1_4_manifest: Boolean get() = componentListAndHasPre14Manifest.second
|
||||||
access.inPlace { it.pre_1_4_manifest.exists }
|
|
||||||
}
|
|
||||||
|
|
||||||
override val manifestProperties: Properties by lazy {
|
override val manifestProperties: Properties by lazy {
|
||||||
access.inPlace { it.manifestFile.loadProperties() }
|
access.inPlace { it.manifestFile.loadProperties() }
|
||||||
|
|||||||
Reference in New Issue
Block a user