diff --git a/runtime/src/main/cpp/KString.cpp b/runtime/src/main/cpp/KString.cpp index 4322937693a..c58f7027c84 100644 --- a/runtime/src/main/cpp/KString.cpp +++ b/runtime/src/main/cpp/KString.cpp @@ -1060,6 +1060,10 @@ KInt Kotlin_String_indexOfString(KString thiz, KString other, KInt fromIndex) { other->count_ > thiz->count_ - fromIndex) { return -1; } + // An empty string can be always found. + if (other->count_ == 0) { + return fromIndex; + } KInt count = thiz->count_; const KChar* thizRaw = CharArrayAddressOfElementAt(thiz, fromIndex); const KChar* otherRaw = CharArrayAddressOfElementAt(other, 0); diff --git a/runtime/src/main/kotlin/kotlin/text/Strings.kt b/runtime/src/main/kotlin/kotlin/text/Strings.kt index 282acd80858..7a32ded565d 100644 --- a/runtime/src/main/kotlin/kotlin/text/Strings.kt +++ b/runtime/src/main/kotlin/kotlin/text/Strings.kt @@ -640,10 +640,6 @@ public fun String.replaceBeforeLast(delimiter: String, replacement: String, miss return if (index == -1) missingDelimiterValue else replaceRange(0, index, replacement) } - -// public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean): String // JVM- and JS-specific -// public fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean): String // JVM- and JS-specific - /** * Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression * with the given [replacement].