Implement CharSequence.regionMatches and generalize depending String extensions to take CharSequence.

Add hidden declarations for replaced overloads with String receiver in hand-written code.
This commit is contained in:
Ilya Gorbunov
2015-10-14 05:22:44 +03:00
parent 47560d3db1
commit e155e426c2
5 changed files with 132 additions and 346 deletions
+2 -8
View File
@@ -54,14 +54,8 @@ public fun String?.equals(anotherString: String?, ignoreCase: Boolean = false):
anotherString != null && this.toLowerCase() == anotherString.toLowerCase()
public fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean {
if ((otherOffset < 0) || (thisOffset < 0) || (thisOffset > length() - length)
|| (otherOffset > other.length() - length)) {
return false;
}
return substring(thisOffset, thisOffset + length).equals(other.substring(otherOffset, otherOffset + length), ignoreCase)
}
public fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean
= regionMatchesImpl(thisOffset, other, otherOffset, length, ignoreCase)
/**