diff --git a/runtime/src/main/kotlin/kotlin/collections/HashMap.kt b/runtime/src/main/kotlin/kotlin/collections/HashMap.kt index 63893db0d85..4757343ccd1 100644 --- a/runtime/src/main/kotlin/kotlin/collections/HashMap.kt +++ b/runtime/src/main/kotlin/kotlin/collections/HashMap.kt @@ -511,9 +511,11 @@ actual class HashMap private constructor( const val INITIAL_MAX_PROBE_DISTANCE = 2 const val TOMBSTONE = -1 - fun computeHashSize(capacity: Int): Int = (capacity.coerceAtLeast(1) * 3).highestOneBit() + @UseExperimental(ExperimentalStdlibApi::class) + fun computeHashSize(capacity: Int): Int = (capacity.coerceAtLeast(1) * 3).takeHighestOneBit() - fun computeShift(hashSize: Int): Int = hashSize.numberOfLeadingZeros() + 1 + @UseExperimental(ExperimentalStdlibApi::class) + fun computeShift(hashSize: Int): Int = hashSize.countLeadingZeroBits() + 1 } internal open class Itr( diff --git a/runtime/src/main/kotlin/kotlin/collections/IntUtil.kt b/runtime/src/main/kotlin/kotlin/collections/IntUtil.kt deleted file mode 100644 index d2d901fa059..00000000000 --- a/runtime/src/main/kotlin/kotlin/collections/IntUtil.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -package kotlin.collections - -internal fun Int.highestOneBit() : Int { - var index = 31 - - while (index >= 0) { - var mask = (1 shl index) - if ((mask and this) != 0) { - return mask - } - index-- - } - return 0 -} - -internal fun Int.numberOfLeadingZeros() : Int { - var index = 31 - - while (index >= 0) { - var mask = (1 shl index) - if ((mask and this) != 0) { - return 31 - index - } - index-- - } - return 0 -} \ No newline at end of file