Extend the coverage of the fast path in the UTF16 comparator to more than ascii.

Swift SVN r18180
This commit is contained in:
Nadav Rotem
2014-05-16 05:58:39 +00:00
parent ccd282df1d
commit 70dfa94160

View File

@@ -124,7 +124,12 @@ extension String {
let e1 = self._base._nthContiguous(aIdx)
let e2 = other._base._nthContiguous(bIdx)
if _slowPath((e1 >= 0x80) | (e2 >= 0x80)) {
// The range 0xD800 .. 0xDFFF is reserved for lead and trail
// surrogates. In this code we are only comparing against the
// lower bound because most interesting characters are in that
// range. This is conversatively correct since the slow path is
// handling the surrogates correctly.
if _slowPath((e1 >= 0xD800) | (e2 >= 0xD800)) {
// Use slow unicode comparator if
// we found multi-byte scalar.
return _compareUnicode(other)