Stabilize new string and char case conversion API KT-45873

This commit is contained in:
Ilya Gorbunov
2021-04-03 00:32:20 +03:00
parent 256f634e61
commit 35ae913a5e
11 changed files with 115 additions and 133 deletions
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.text
@@ -161,8 +161,8 @@ public actual fun Char.toUpperCase(): Char = uppercaseCharImpl()
*
* @sample samples.text.Chars.uppercase
*/
@SinceKotlin("1.4")
@ExperimentalStdlibApi
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public actual fun Char.uppercaseChar(): Char = uppercaseCharImpl()
/**
@@ -175,8 +175,8 @@ public actual fun Char.uppercaseChar(): Char = uppercaseCharImpl()
*
* @sample samples.text.Chars.uppercase
*/
@SinceKotlin("1.4")
@ExperimentalStdlibApi
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public actual fun Char.uppercase(): String = uppercaseImpl()
/**
@@ -193,8 +193,8 @@ public actual fun Char.toLowerCase(): Char = lowercaseCharImpl()
*
* @sample samples.text.Chars.lowercase
*/
@SinceKotlin("1.4")
@ExperimentalStdlibApi
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public actual fun Char.lowercaseChar(): Char = lowercaseCharImpl()
/**
@@ -207,8 +207,8 @@ public actual fun Char.lowercaseChar(): Char = lowercaseCharImpl()
*
* @sample samples.text.Chars.lowercase
*/
@SinceKotlin("1.4")
@ExperimentalStdlibApi
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public actual fun Char.lowercase(): String = lowercaseImpl()
/**
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.text
@@ -62,7 +62,6 @@ public actual fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boole
@SymbolName("Kotlin_String_replace")
private external fun String.replace(oldChar: Char, newChar: Char): String
@OptIn(ExperimentalStdlibApi::class)
private fun String.replaceIgnoreCase(oldChar: Char, newChar: Char): String {
val charArray = CharArray(length)
val oldCharLower = oldChar.lowercaseChar()
@@ -185,7 +184,6 @@ public fun String.regionMatches(
private external fun String.unsafeRangeEquals(thisOffset: Int, other: String, otherOffset: Int, length: Int): Boolean
// Bounds must be checked before calling this method
@OptIn(ExperimentalStdlibApi::class)
private fun String.unsafeRangeEqualsIgnoreCase(thisOffset: Int, other: String, otherOffset: Int, length: Int): Boolean {
for (index in 0 until length) {
val thisCharLower = this[thisOffset + index].lowercaseChar()
@@ -210,8 +208,8 @@ public actual fun String.toUpperCase(): String = uppercaseImpl()
*
* @sample samples.text.Strings.uppercase
*/
@SinceKotlin("1.4")
@ExperimentalStdlibApi
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public actual fun String.uppercase(): String = uppercaseImpl()
/**
@@ -227,8 +225,8 @@ public actual fun String.toLowerCase(): String = lowercaseImpl()
*
* @sample samples.text.Strings.lowercase
*/
@SinceKotlin("1.4")
@ExperimentalStdlibApi
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public actual fun String.lowercase(): String = lowercaseImpl()
/**
@@ -401,7 +399,6 @@ public actual fun String.encodeToByteArray(startIndex: Int, endIndex: Int, throw
unsafeStringToUtf8(startIndex, endIndex - startIndex)
}
@OptIn(ExperimentalStdlibApi::class)
internal fun compareToIgnoreCase(thiz: String, other: String): Int {
val length = minOf(thiz.length, other.length)