Super slow compilation and IntelliJ freezing after...
# getting-started
d
Super slow compilation and IntelliJ freezing after creating around 1500 Kotlin files (with code generation) 🧵
I'm working on a code generator that makes kotlin bindings for the Vulkan API (sort of, it create kotlin extension on top of LWJGL's Vulkan bindings for Java).
I'm creating quite a few files, around 1500 files. Some are classes, a lot are just files with extension methods/properties for existing Java classes.
It seems to really slow down things when I add more extension methods and properties.
Example of some generated code:
Copy code
var VkGraphicsPipelineCreateInfo.flags
    get() = VkPipelineCreateFlags.of(flags())
    set(value) {
        flags(value.value)
    }

@OptIn(ExperimentalContracts::class)
inline fun VkGraphicsPipelineCreateInfo.flags(builder: VkPipelineCreateFlags.Companion.() -> VkPipelineCreateFlags): VkGraphicsPipelineCreateInfo {
    contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) }
    return flags(builder(VkPipelineCreateFlags).value)
}

fun VkGraphicsPipelineCreateInfo.flags(value: VkPipelineCreateFlags): VkGraphicsPipelineCreateInfo {
    return flags(value.value)
}
I'm wondering if the style of code I'm creating is just slower to compile, or if its just a function of the amount of code.
Well, it appears that simply having so many extension methods in the same package was what slowed things down. When I moved them into data objects for namespacing purposes, it sped up the IDE a lot.