diff --git a/runtime/src/main/kotlin/kotlin/collections/Maps.kt b/runtime/src/main/kotlin/kotlin/collections/Maps.kt index 8d7203e48c6..e511d99317c 100644 --- a/runtime/src/main/kotlin/kotlin/collections/Maps.kt +++ b/runtime/src/main/kotlin/kotlin/collections/Maps.kt @@ -12,3 +12,21 @@ internal inline actual fun Map.toSingletonMapOrSelf(): Map = // creates a singleton copy of map internal actual fun Map.toSingletonMap(): Map = with(entries.iterator().next()) { mutableMapOf(key to value) } + + +/** + * Native map and set implementations do not make use of capacities or load factors. + */ +@PublishedApi +internal actual fun mapCapacity(expectedSize: Int) = expectedSize + +/** + * Checks a collection builder function capacity argument. + * Does nothing, capacity is validated in List/Set/Map constructor + */ +@SinceKotlin("1.3") +@ExperimentalStdlibApi +@PublishedApi +internal actual fun checkBuilderCapacity(capacity: Int) { + require(capacity >= 0) { "capacity must be non-negative." } +} \ No newline at end of file