Optimizations in listOf and arrayListOf constructor functions.
Remove linkedListOf() from JS. #KT-5703 Fixed #KT-8519 Fixed
This commit is contained in:
@@ -16,34 +16,13 @@
|
||||
|
||||
package java.util
|
||||
|
||||
public fun HashSet<E>(c: Collection<E>): HashSet<E> {
|
||||
val set: HashSet<E> = HashSet(c.size())
|
||||
set.addAll(c)
|
||||
return set
|
||||
}
|
||||
public fun HashSet<E>(c: Collection<E>): HashSet<E> = HashSet<E>(c.size()).apply { addAll(c) }
|
||||
|
||||
public fun LinkedHashSet<E>(c: Collection<E>): HashSet<E> {
|
||||
val set: LinkedHashSet<E> = LinkedHashSet(c.size())
|
||||
set.addAll(c)
|
||||
return set
|
||||
}
|
||||
public fun LinkedHashSet<E>(c: Collection<E>): HashSet<E> = LinkedHashSet<E>(c.size()).apply { addAll(c) }
|
||||
|
||||
public fun HashMap<K, V>(m: Map<K, V>): HashMap<K, V> {
|
||||
val map: HashMap<K, V> = HashMap(m.size())
|
||||
map.putAll(m)
|
||||
return map
|
||||
}
|
||||
public fun HashMap<K, V>(m: Map<K, V>): HashMap<K, V> = HashMap<K, V>(m.size()).apply { putAll(m) }
|
||||
|
||||
public fun LinkedHashMap<K, V>(m: Map<K, V>): LinkedHashMap<K, V> {
|
||||
val map: LinkedHashMap<K, V> = LinkedHashMap(m.size())
|
||||
map.putAll(m)
|
||||
return map
|
||||
}
|
||||
public fun LinkedHashMap<K, V>(m: Map<K, V>): LinkedHashMap<K, V> = LinkedHashMap<K, V>(m.size()).apply { putAll(m) }
|
||||
|
||||
public fun ArrayList<E>(c: Collection<E>): ArrayList<E> = ArrayList<E>().apply { asDynamic().array = c.toTypedArray<Any?>() } // black dynamic magic
|
||||
|
||||
public fun ArrayList<E>(c: Collection<E>): ArrayList<E> {
|
||||
val result = ArrayList<E>()
|
||||
for (element in c) {
|
||||
result.add(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user