Minimize references to java.util.Collections in stdlib sources

Only three usages are left in platform-independent code: in reverse, sort and
sortWith for mutable lists
This commit is contained in:
Alexander Udalov
2016-11-01 16:24:42 +03:00
parent b52f67132e
commit 30a7790dca
10 changed files with 12 additions and 30 deletions
@@ -38,7 +38,6 @@ fun List<GenericFunction>.writeTo(file: File, builder: GenericFunction.() -> Str
its.append("package kotlin.collections\n\n")
its.append("$COMMON_AUTOGENERATED_WARNING\n\n")
its.append("import java.util.*\n\n")
its.append("import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js\n\n")
for (t in this.sortedBy { it.signature }) {
its.append(t.builder())
}
@@ -59,7 +58,6 @@ fun List<ConcreteFunction>.writeTo(outDir: File, sourceFile: SourceFile) {
its.append("$COMMON_AUTOGENERATED_WARNING\n\n")
its.append("import kotlin.comparisons.*\n")
its.append("import java.util.*\n\n")
its.append("import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js\n\n")
for (f in this) {
f.textBuilder(its)
@@ -33,7 +33,7 @@ fun ordering(): List<GenericFunction> {
"""
if (this is Collection && size <= 1) return toList()
val list = toMutableList()
Collections.reverse(list)
list.reverse()
return list
"""
}
@@ -42,7 +42,7 @@ fun ordering(): List<GenericFunction> {
"""
if (isEmpty()) return emptyList()
val list = toMutableList()
Collections.reverse(list)
list.reverse()
return list
"""
}