[JS IR] Remove unused code & comments & style fixes
^KT-59001
This commit is contained in:
committed by
Space Team
parent
2300facead
commit
f834007da6
@@ -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.
|
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||||
*/
|
*/
|
||||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this() {
|
actual constructor(initialCapacity: Int, loadFactor: Float) : this(InternalHashMap(initialCapacity, loadFactor))
|
||||||
// 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" }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty [HashMap] with the specified initial capacity.
|
* 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.
|
* Creates a new [HashMap] filled with the contents of the specified [original] map.
|
||||||
*/
|
*/
|
||||||
actual constructor(original: Map<out K, V>) : this() {
|
actual constructor(original: Map<out K, V>) : this(InternalHashMap(original))
|
||||||
this.putAll(original)
|
|
||||||
}
|
|
||||||
|
|
||||||
actual override fun clear() {
|
actual override fun clear() {
|
||||||
internalMap.clear()
|
internalMap.clear()
|
||||||
// structureChanged(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actual override fun containsKey(key: K): Boolean = internalMap.contains(key)
|
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 isEmpty(): Boolean = _size == 0
|
||||||
fun containsKey(key: K): Boolean = findKey(key) >= 0
|
|
||||||
override fun containsValue(value: V): Boolean = findValue(value) >= 0
|
override fun containsValue(value: V): Boolean = findValue(value) >= 0
|
||||||
|
|
||||||
override operator fun get(key: K): V? {
|
override operator fun get(key: K): V? {
|
||||||
@@ -90,11 +89,10 @@ internal class InternalHashMap<K, V> private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun contains(key: K): Boolean {
|
override fun contains(key: K): Boolean {
|
||||||
return containsKey(key)
|
return findKey(key) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun put(key: K, value: V): V? {
|
override fun put(key: K, value: V): V? {
|
||||||
checkIsMutable()
|
|
||||||
val index = addKey(key)
|
val index = addKey(key)
|
||||||
val valuesArray = allocateValuesArray()
|
val valuesArray = allocateValuesArray()
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
@@ -286,7 +284,7 @@ internal class InternalHashMap<K, V> private constructor(
|
|||||||
return TOMBSTONE
|
return TOMBSTONE
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun addKey(key: K): Int {
|
private fun addKey(key: K): Int {
|
||||||
checkIsMutable()
|
checkIsMutable()
|
||||||
retry@ while (true) {
|
retry@ while (true) {
|
||||||
var hash = hash(key)
|
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()
|
checkIsMutable()
|
||||||
val index = findKey(key)
|
val index = findKey(key)
|
||||||
if (index < 0) return TOMBSTONE
|
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 contentEquals(other: Map<*, *>): Boolean = _size == other.size && containsAllEntries(other.entries)
|
||||||
|
|
||||||
private fun putEntry(entry: Map.Entry<K, V>): Boolean {
|
private fun putEntry(entry: Map.Entry<K, V>): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user