[string] Skip unnecessary self UTF-16 length in isEqual

For isEqual bridging comparisons, skip checking our own UTF-16 length when the
string we're comparing against is known to be ASCII.
This commit is contained in:
Michael Ilseman
2020-03-05 14:46:37 -08:00
parent 0ca42e9ef7
commit 7ff3ecf2e5
2 changed files with 11 additions and 1 deletions

View File

@@ -531,6 +531,8 @@ extension String.UTF16View {
let idx = _utf16AlignNativeIndex(idx)
guard _guts._useBreadcrumbs(forEncodedOffset: idx._encodedOffset) else {
// TODO: Generic _distance is still very slow. We should be able to
// skip over ASCII substrings quickly
return _distance(from: startIndex, to: idx)
}