summaryrefslogtreecommitdiff
path: root/formats/json/jsMain/src/kotlinx/serialization/json/internal/createMapForCache.kt
blob: b51ff401b8af2df012e1f381cfac4b4d0e43c7f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/*
 * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package kotlinx.serialization.json.internal

/**
 * Creates a ConcurrentHashMap on JVM and regular HashMap on other platforms.
 * To make actual use of cache in Kotlin/Native, mark a top-level object with this map
 * as a @[ThreadLocal].
 */
internal actual fun <K, V> createMapForCache(initialCapacity: Int): MutableMap<K, V> = HashMap(initialCapacity)