mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
If there are multiple copies of the same library on the classpath, then ShadowedDeclarationsFilter becomes very slow because it encounters many equal-signature declarations and thus has to resolve a lot of calls in order to pick among them. Having multiple copies of the same library on the classpath is somewhat common in real-world projects. It occurs in the JetBrains/intellij-kotlin project, for example. In that project, ShadowedDeclarationsFilter ends up resolving thousands of calls, accounting for around 80% of completion time when there are many completion results (see KT-44276). We can optimize ShadowedDeclarationsFilter by checking whether the descriptors in an equal-signature group are structurally equivalent. If they are, we can just pick one rather than running resolve. Testing on a small project with Kotlin stdlib duplicated on the classpath, this change reduces overhead in ShadowedDeclarationsFilter from 1200 ms to 20 ms when running completion on the prefix 'a'. End-to-end completion time is cut in half. Test: JvmBasicCompletionTestGenerated.Common.Shadowing