From f2e489a2f23467f99cbf1f5d83716ce8aad1680a Mon Sep 17 00:00:00 2001 From: Yang Date: Sun, 30 Apr 2023 14:29:36 +1000 Subject: [PATCH] Simplify `actual` implementations. --- .../cache4k/ConcurrentMutableMap.kt | 22 +++++-------------- .../cache4k/ConcurrentMutableMap.kt | 22 +++++-------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/cache4k/src/jvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt b/cache4k/src/jvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt index 40ee1e5..f63f129 100644 --- a/cache4k/src/jvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt +++ b/cache4k/src/jvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt @@ -5,25 +5,15 @@ import java.util.concurrent.ConcurrentHashMap internal actual class ConcurrentMutableMap { private val map = ConcurrentHashMap() - actual val size: Int - get() = map.size + actual val size: Int get() = map.size - actual val values: Collection - get() = map.values + actual val values: Collection get() = map.values - actual operator fun get(key: Key): Value? { - return map[key] - } + actual operator fun get(key: Key): Value? = map[key] - actual fun put(key: Key, value: Value): Value? { - return map.put(key, value) - } + actual fun put(key: Key, value: Value): Value? = map.put(key, value) - actual fun remove(key: Key): Value? { - return map.remove(key) - } + actual fun remove(key: Key): Value? = map.remove(key) - actual fun clear() { - map.clear() - } + actual fun clear() = map.clear() } diff --git a/cache4k/src/nonJvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt b/cache4k/src/nonJvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt index a43c0c2..ff14e29 100644 --- a/cache4k/src/nonJvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt +++ b/cache4k/src/nonJvmMain/kotlin/io/github/reactivecircus/cache4k/ConcurrentMutableMap.kt @@ -5,25 +5,15 @@ import co.touchlab.stately.collections.IsoMutableMap internal actual class ConcurrentMutableMap { private val map = IsoMutableMap() - actual val size: Int - get() = map.size + actual val size: Int get() = map.size - actual val values: Collection - get() = map.values + actual val values: Collection get() = map.values - actual operator fun get(key: Key): Value? { - return map[key] - } + actual operator fun get(key: Key): Value? = map[key] - actual fun put(key: Key, value: Value): Value? { - return map.put(key, value) - } + actual fun put(key: Key, value: Value): Value? = map.put(key, value) - actual fun remove(key: Key): Value? { - return map.remove(key) - } + actual fun remove(key: Key): Value? = map.remove(key) - actual fun clear() { - map.clear() - } + actual fun clear() = map.clear() }