From b76de2a6040beb10a4782d23756b58c2ce24e157 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Tue, 11 Nov 2025 06:45:50 +0100 Subject: [PATCH] cleanup [syntax]: simplify web implementations GitOrigin-RevId: 32733fe2605ecc087032ad9997e1af244ddd0916 --- .../platform/syntax/extensions/impl/CollectionsImplJs.kt | 8 ++------ .../syntax/extensions/impl/CollectionsImplWasmJs.kt | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/platform/syntax/syntax-extensions/srcJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplJs.kt b/platform/syntax/syntax-extensions/srcJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplJs.kt index bd4e3ec8fcad..87423d26b24d 100644 --- a/platform/syntax/syntax-extensions/srcJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplJs.kt +++ b/platform/syntax/syntax-extensions/srcJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplJs.kt @@ -21,14 +21,10 @@ private class SyntaxConcurrentMapJs() : MultiplatformConcurren override val keys: Set get() = map.keys - override fun computeIfAbsent(key: K, f: (K) -> V): V = map[key] ?: f(key).also { map[key] = it } + override fun computeIfAbsent(key: K, f: (K) -> V): V = map.getOrPut(key) { f(key) } override fun get(key: K): V? = map[key] override fun remove(key: K): V? = map.remove(key) - override fun put(key: K, value: V): V? { - val prevValue = map[key] - map[key] = value - return prevValue - } + override fun put(key: K, value: V): V? = map.put(key, value) override fun hashCode(): Int = map.hashCode() override fun toString(): String = map.toString() override fun equals(other: Any?): Boolean { diff --git a/platform/syntax/syntax-extensions/srcWasmJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplWasmJs.kt b/platform/syntax/syntax-extensions/srcWasmJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplWasmJs.kt index e3335590e2ee..a0a9a10e0fe3 100644 --- a/platform/syntax/syntax-extensions/srcWasmJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplWasmJs.kt +++ b/platform/syntax/syntax-extensions/srcWasmJsMain/com/intellij/platform/syntax/extensions/impl/CollectionsImplWasmJs.kt @@ -21,14 +21,10 @@ private class SyntaxConcurrentMapWasmJs() : MultiplatformConcu override val keys: Set get() = map.keys - override fun computeIfAbsent(key: K, f: (K) -> V): V = map[key] ?: f(key).also { map[key] = it } + override fun computeIfAbsent(key: K, f: (K) -> V): V = map.getOrPut(key) { f(key) } override fun get(key: K): V? = map[key] override fun remove(key: K): V? = map.remove(key) - override fun put(key: K, value: V): V? { - val prevValue = map[key] - map[key] = value - return prevValue - } + override fun put(key: K, value: V): V? = map.put(key, value) override fun hashCode(): Int = map.hashCode() override fun toString(): String = map.toString() override fun equals(other: Any?): Boolean {