Skip to content

Commit 99da6d3

Browse files
BlaBlaHumanSpace Team
authored and
Space Team
committed
[Analysis API] Optimize KotlinOptimizingGlobalSearchScopeMerger.applyStrategy
^KT-77135
1 parent 81b5f3a commit 99da6d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

analysis/analysis-api-impl-base/src/org/jetbrains/kotlin/analysis/api/impl/base/projectStructure/KotlinOptimizingGlobalSearchScopeMerger.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ internal class KotlinOptimizingGlobalSearchScopeMerger(private val project: Proj
3030

3131
@OptIn(KaExperimentalApi::class)
3232
private fun <T : Any> Collection<GlobalSearchScope>.applyStrategy(strategy: KotlinGlobalSearchScopeMergeStrategy<T>): Collection<GlobalSearchScope> {
33-
val applicableScopes = this.filterIsInstance(strategy.targetType.java).ifEmpty { return this@applyStrategy }
33+
val (applicableScopes, restScopes) = this.partition { strategy.targetType.isInstance(it) }
34+
if (applicableScopes.isEmpty()) {
35+
return this
36+
}
3437

3538
@Suppress("UNCHECKED_CAST")
36-
val restScopes = (this - applicableScopes) as List<GlobalSearchScope>
37-
return strategy.uniteScopes(applicableScopes) + restScopes
39+
return strategy.uniteScopes(applicableScopes as List<T>) + restScopes
3840
}
3941
}

0 commit comments

Comments
 (0)