From 21a271d2a1298b8a86a5e3a45ecd012c3c9447cb Mon Sep 17 00:00:00 2001 From: Alexander Koshevoy Date: Mon, 27 Oct 2025 18:51:37 +0100 Subject: [PATCH] [eel][sdk] IJPL-214464 Streamline getAllSdks() to avoid extra allocations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the hot `getAllSdks()` path by dropping an intermediate `map { it.currentSnapshot }` stage and the trailing `toList()`. We now `flatMap` global workspace models directly to each model's `currentSnapshot` and `mapNotNull` its `SdkEntity` → `Sdk` mapping in one pass. This removes an unnecessary snapshots list and the final materialization while preserving ordering and results, reducing minor CPU and allocation overhead in frequent SDK lookups tied to IJPL‑214464. (cherry picked from commit fa5f907f06f0fd8cca25550283061ec126c7c93d) IJ-CR-180956 GitOrigin-RevId: fb02b0f6fc6eb46a59f33f1ab36e1439e745065e --- .../ide/impl/legacyBridge/sdk/SdkTableBridgeImpl.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/sdk/SdkTableBridgeImpl.kt b/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/sdk/SdkTableBridgeImpl.kt index b8810516ca1f..bfa8783f5764 100644 --- a/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/sdk/SdkTableBridgeImpl.kt +++ b/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/sdk/SdkTableBridgeImpl.kt @@ -50,11 +50,10 @@ class SdkTableBridgeImpl: SdkTableImplementationDelegate { override fun getAllSdks(): List { val globalWorkspaceModels = GlobalWorkspaceModel.getInstancesBlocking() - return globalWorkspaceModels.map { - it.currentSnapshot - }.flatMap { snapshot -> - snapshot.entities(SdkEntity::class.java).mapNotNull { snapshot.sdkMap.getDataByEntity(it) } - }.toList() + return globalWorkspaceModels.flatMap { + val snapshot = it.currentSnapshot + snapshot.entities(SdkEntity::class.java).mapNotNull { sdkEntity -> snapshot.sdkMap.getDataByEntity(sdkEntity) } + } } override fun createSdk(name: String, type: SdkTypeId, homePath: String?): Sdk {