[JS IR] Remove unused code & comments & style fixes

^KT-59001
This commit is contained in:
Alexander Korepanov
2023-06-20 18:38:41 +02:00
committed by Space Team
parent 2300facead
commit f834007da6
2 changed files with 5 additions and 23 deletions
@@ -48,11 +48,7 @@ public actual open class HashMap<K, V> : AbstractMutableMap<K, V>, MutableMap<K,
*
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
*/
actual constructor(initialCapacity: Int, loadFactor: Float) : this() {
// This implementation of HashMap has no need of load factors or capacities.
require(initialCapacity >= 0) { "Negative initial capacity: $initialCapacity" }
require(loadFactor > 0) { "Non-positive load factor: $loadFactor" }
}
actual constructor(initialCapacity: Int, loadFactor: Float) : this(InternalHashMap(initialCapacity, loadFactor))
/**
* Creates a new empty [HashMap] with the specified initial capacity.
@@ -71,13 +67,10 @@ public actual open class HashMap<K, V> : AbstractMutableMap<K, V>, MutableMap<K,
/**
* Creates a new [HashMap] filled with the contents of the specified [original] map.
*/
actual constructor(original: Map<out K, V>) : this() {
this.putAll(original)
}
actual constructor(original: Map<out K, V>) : this(InternalHashMap(original))
actual override fun clear() {
internalMap.clear()
// structureChanged(this)
}
actual override fun containsKey(key: K): Boolean = internalMap.contains(key)
@@ -80,7 +80,6 @@ internal class InternalHashMap<K, V> private constructor(
}
fun isEmpty(): Boolean = _size == 0
fun containsKey(key: K): Boolean = findKey(key) >= 0
override fun containsValue(value: V): Boolean = findValue(value) >= 0
override operator fun get(key: K): V? {
@@ -90,11 +89,10 @@ internal class InternalHashMap<K, V> private constructor(
}
override fun contains(key: K): Boolean {
return containsKey(key)
return findKey(key) >= 0
}
override fun put(key: K, value: V): V? {
checkIsMutable()
val index = addKey(key)
val valuesArray = allocateValuesArray()
if (index < 0) {
@@ -286,7 +284,7 @@ internal class InternalHashMap<K, V> private constructor(
return TOMBSTONE
}
internal fun addKey(key: K): Int {
private fun addKey(key: K): Int {
checkIsMutable()
retry@ while (true) {
var hash = hash(key)
@@ -320,7 +318,7 @@ internal class InternalHashMap<K, V> private constructor(
}
}
internal fun removeKey(key: K): Int {
private fun removeKey(key: K): Int {
checkIsMutable()
val index = findKey(key)
if (index < 0) return TOMBSTONE
@@ -405,15 +403,6 @@ internal class InternalHashMap<K, V> private constructor(
}
}
internal fun getKey(key: K): K? {
val index = findKey(key)
return if (index >= 0) {
keysArray[index]!!
} else {
null
}
}
private fun contentEquals(other: Map<*, *>): Boolean = _size == other.size && containsAllEntries(other.entries)
private fun putEntry(entry: Map.Entry<K, V>): Boolean {