Skip to content

Commit 66b294f

Browse files
WindowsMEMZelsakeirouz
authored andcommitted
Add isIdentical to StringGuts and use it for comparation
1 parent 6184b4a commit 66b294f

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

stdlib/public/core/StringGuts.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ extension _StringGuts {
418418
}
419419
}
420420

421+
extension _StringGuts {
422+
@inline(__always) // Performance
423+
internal func isTriviallyIdentical(to other: Self) -> Bool {
424+
self.rawBits == other.rawBits
425+
}
426+
}
427+
421428
#if _runtime(_ObjC)
422429
extension _StringGuts {
423430

stdlib/public/core/StringUTF16View.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,6 @@ extension String.UTF16View {
10641064
/// - Complexity: O(1)
10651065
@available(SwiftStdlib 6.3, *)
10661066
public func isTriviallyIdentical(to other: Self) -> Bool {
1067-
self._guts.rawBits == other._guts.rawBits
1067+
self._guts.isTriviallyIdentical(to: other._guts)
10681068
}
10691069
}

stdlib/public/core/StringUTF8View.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,6 @@ extension String.UTF8View {
692692
/// - Complexity: O(1)
693693
@available(SwiftStdlib 6.3, *)
694694
public func isTriviallyIdentical(to other: Self) -> Bool {
695-
self._guts.rawBits == other._guts.rawBits
695+
self._guts.isTriviallyIdentical(to: other._guts)
696696
}
697697
}

stdlib/public/core/StringUnicodeScalarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,6 @@ extension String.UnicodeScalarView {
535535
/// - Complexity: O(1)
536536
@available(SwiftStdlib 6.3, *)
537537
public func isTriviallyIdentical(to other: Self) -> Bool {
538-
self._guts.rawBits == other._guts.rawBits
538+
self._guts.isTriviallyIdentical(to: other._guts)
539539
}
540540
}

0 commit comments

Comments
 (0)