_BString: Add isIdentical(to:) to all string views

This commit is contained in:
Karoy Lorentey committed 2023-03-20 13:12:14 -07:00
1 parent b50fb5aab5
commit da78365bef
6 files changed
+27

No files matched your search

@@ -37,6 +37,10 @@ extension _BString.UTF16View: Equatable {
internal static func ==(left: Self, right: Self) -> Bool {
_BString.utf8IsEqual(left._base, to: right._base)
}
internal func isIdentical(to other: Self) -> Bool {
self._base.isIdentical(to: other._base)
}
}
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)
@@ -37,6 +37,10 @@ extension _BString.UTF8View: Equatable {
internal static func ==(left: Self, right: Self) -> Bool {
_BString.utf8IsEqual(left._base, to: right._base)
}
internal func isIdentical(to other: Self) -> Bool {
self._base.isIdentical(to: other._base)
}
}
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)
@@ -71,6 +71,10 @@ extension _BString.UnicodeScalarView: Equatable {
internal static func ==(left: Self, right: Self) -> Bool {
_BString.utf8IsEqual(left._base, to: right._base)
}
internal func isIdentical(to other: Self) -> Bool {
self._base.isIdentical(to: other._base)
}
}
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)
@@ -85,6 +85,11 @@ extension _BSubstring.UTF16View: Equatable {
return _BString.utf8IsEqual(left._base, in: i1 ..< j1, to: right._base, in: i2 ..< j2)
}
internal func isIdentical(to other: Self) -> Bool {
guard self._base.isIdentical(to: other._base) else { return false }
return self._bounds == other._bounds
}
}
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)
@@ -62,6 +62,11 @@ extension _BSubstring.UTF8View: Equatable {
internal static func ==(left: Self, right: Self) -> Bool {
_BString.utf8IsEqual(left._base, in: left._bounds, to: right._base, in: right._bounds)
}
internal func isIdentical(to other: Self) -> Bool {
guard self._base.isIdentical(to: other._base) else { return false }
return self._bounds == other._bounds
}
}
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)
@@ -90,6 +90,11 @@ extension _BSubstring.UnicodeScalarView: Equatable {
internal static func ==(left: Self, right: Self) -> Bool {
_BString.utf8IsEqual(left._base, in: left._bounds, to: right._base, in: right._bounds)
}
internal func isIdentical(to other: Self) -> Bool {
guard self._base.isIdentical(to: other._base) else { return false }
return self._bounds == other._bounds
}
}
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)