Remove previous internal implementations of bit extensions

This commit is contained in:
Ilya Gorbunov
2019-07-03 02:25:33 +03:00
parent 28724409bf
commit 782b6d8534
2 changed files with 4 additions and 34 deletions
@@ -511,9 +511,11 @@ actual class HashMap<K, V> 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<K, V>(
@@ -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
}