Nullable Array.contentEquals/contentHashCode/contentToString #KT-34161

This commit is contained in:
Abduqodiri Qurbonzoda
2020-02-27 14:44:33 +03:00
parent 179ec41a6b
commit e632d58936
16 changed files with 1897 additions and 133 deletions
@@ -72,9 +72,9 @@ public inline fun <C, R> C.ifEmpty(defaultValue: () -> R): R where C : Array<*>,
@PublishedApi
@kotlin.jvm.JvmName("contentDeepEquals")
@kotlin.js.JsName("contentDeepEqualsImpl")
internal fun <T> Array<out T>.contentDeepEqualsImpl(other: Array<out T>): Boolean {
internal fun <T> Array<out T>?.contentDeepEqualsImpl(other: Array<out T>?): Boolean {
if (this === other) return true
if (this.size != other.size) return false
if (this == null || other == null || this.size != other.size) return false
for (i in indices) {
val v1 = this[i]
@@ -113,7 +113,8 @@ internal fun <T> Array<out T>.contentDeepEqualsImpl(other: Array<out T>): Boolea
@PublishedApi
@kotlin.jvm.JvmName("contentDeepToString")
@kotlin.js.JsName("contentDeepToStringImpl")
internal fun <T> Array<out T>.contentDeepToStringImpl(): String {
internal fun <T> Array<out T>?.contentDeepToStringImpl(): String {
if (this == null) return "null"
val length = size.coerceAtMost((Int.MAX_VALUE - 2) / 5) * 5 + 2 // in order not to overflow Int.MAX_VALUE
return buildString(length) {
contentDeepToStringInternal(this, mutableListOf())