File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,17 @@ extension String {
53
53
/// - Precondition: Both `self` and `rhs` are ASCII strings.
54
54
public // @testable
55
55
func _compareASCII( _ rhs: String ) -> Int {
56
- var compare = Int ( extendingOrTruncating: _swift_stdlib_memcmp (
57
- self . _core. startASCII, rhs. _core. startASCII,
58
- Swift . min ( self . _core. count, rhs. _core. count) ) )
56
+ var compare : Int
57
+
58
+ if self . _core. startASCII == rhs. _core. startASCII {
59
+ compare = 0
60
+ }
61
+ else {
62
+ compare = Int ( extendingOrTruncating: _swift_stdlib_memcmp (
63
+ self . _core. startASCII, rhs. _core. startASCII,
64
+ Swift . min ( self . _core. count, rhs. _core. count) ) )
65
+ }
66
+
59
67
if compare == 0 {
60
68
compare = self . _core. count - rhs. _core. count
61
69
}
@@ -130,6 +138,9 @@ extension String : Equatable {
130
138
if lhs. _core. count != rhs. _core. count {
131
139
return false
132
140
}
141
+ if lhs. _core. startASCII == rhs. _core. startASCII {
142
+ return true
143
+ }
133
144
return _swift_stdlib_memcmp (
134
145
lhs. _core. startASCII, rhs. _core. startASCII,
135
146
rhs. _core. count) == ( 0 as CInt )
You can’t perform that action at this time.
0 commit comments